!function(e, t) {
"object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define("cloudbase", [], t) : "object" == typeof exports ? exports.cloudbase = t() : e.cloudbase = t();
}("undefined" != typeof window ? window : this, function() {
return function(e) {
var t = {};
function n(r) {
if (t[r]) return t[r].exports;
var i = t[r] = {
i: r,
l: !1,
exports: {}
};
return e[r].call(i.exports, i, i.exports, n), i.l = !0, i.exports;
}
return n.m = e, n.c = t, n.d = function(e, t, r) {
n.o(e, t) || Object.defineProperty(e, t, {
enumerable: !0,
get: r
});
}, n.r = function(e) {
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
value: "Module"
}), Object.defineProperty(e, "__esModule", {
value: !0
});
}, n.t = function(e, t) {
if (1 & t && (e = n(e)), 8 & t) return e;
if (4 & t && "object" == typeof e && e && e.__esModule) return e;
var r = Object.create(null);
if (n.r(r), Object.defineProperty(r, "default", {
enumerable: !0,
value: e
}), 2 & t && "string" != typeof e) for (var i in e) n.d(r, i, function(t) {
return e[t];
}.bind(null, i));
return r;
}, n.n = function(e) {
var t = e && e.__esModule ? function() {
return e.default;
} : function() {
return e;
};
return n.d(t, "a", t), t;
}, n.o = function(e, t) {
return Object.prototype.hasOwnProperty.call(e, t);
}, n.p = "", n(n.s = 15);
}([ function(e, t, n) {
"use strict";
var r = this && this.__createBinding || (Object.create ? function(e, t, n, r) {
void 0 === r && (r = n), Object.defineProperty(e, r, {
enumerable: !0,
get: function() {
return t[n];
}
});
} : function(e, t, n, r) {
void 0 === r && (r = n), e[r] = t[n];
}), i = this && this.__setModuleDefault || (Object.create ? function(e, t) {
Object.defineProperty(e, "default", {
enumerable: !0,
value: t
});
} : function(e, t) {
e.default = t;
}), o = this && this.__importStar || function(e) {
if (e && e.__esModule) return e;
var t = {};
if (null != e) for (var n in e) "default" !== n && Object.hasOwnProperty.call(e, n) && r(t, e, n);
return i(t, e), t;
};
Object.defineProperty(t, "__esModule", {
value: !0
}), t.helpers = t.utils = t.events = t.cache = t.adapters = t.constants = void 0;
var s = o(n(9));
t.constants = s;
var a = o(n(19));
t.adapters = a;
var u = o(n(26));
t.cache = u;
var c = o(n(27));
t.events = c;
var f = o(n(5));
t.utils = f;
var l = o(n(28));
t.helpers = l;
}, function(module, __webpack_exports__, __webpack_require__) {
"use strict";
(function(global, Buffer) {
__webpack_require__.d(__webpack_exports__, "a", function() {
return bson_54;
});
var long__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6), long__WEBPACK_IMPORTED_MODULE_0___default = __webpack_require__.n(long__WEBPACK_IMPORTED_MODULE_0__), buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3), buffer__WEBPACK_IMPORTED_MODULE_1___default = __webpack_require__.n(buffer__WEBPACK_IMPORTED_MODULE_1__), commonjsGlobal = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : void 0 !== global ? global : "undefined" != typeof self ? self : {};
function createCommonjsModule(e, t) {
return e(t = {
exports: {}
}, t.exports), t.exports;
}
var map = createCommonjsModule(function(e) {
if (void 0 !== commonjsGlobal.Map) e.exports = commonjsGlobal.Map, e.exports.Map = commonjsGlobal.Map; else {
var t = function(e) {
this._keys = [], this._values = {};
for (var t = 0; t < e.length; t++) if (null != e[t]) {
var n = e[t], r = n[0], i = n[1];
this._keys.push(r), this._values[r] = {
v: i,
i: this._keys.length - 1
};
}
};
t.prototype.clear = function() {
this._keys = [], this._values = {};
}, t.prototype.delete = function(e) {
var t = this._values[e];
return null != t && (delete this._values[e], this._keys.splice(t.i, 1), !0);
}, t.prototype.entries = function() {
var e = this, t = 0;
return {
next: function() {
var n = e._keys[t++];
return {
value: void 0 !== n ? [ n, e._values[n].v ] : void 0,
done: void 0 === n
};
}
};
}, t.prototype.forEach = function(e, t) {
t = t || this;
for (var n = 0; n < this._keys.length; n++) {
var r = this._keys[n];
e.call(t, this._values[r].v, r, t);
}
}, t.prototype.get = function(e) {
return this._values[e] ? this._values[e].v : void 0;
}, t.prototype.has = function(e) {
return null != this._values[e];
}, t.prototype.keys = function() {
var e = this, t = 0;
return {
next: function() {
var n = e._keys[t++];
return {
value: void 0 !== n ? n : void 0,
done: void 0 === n
};
}
};
}, t.prototype.set = function(e, t) {
return this._values[e] ? (this._values[e].v = t, this) : (this._keys.push(e), this._values[e] = {
v: t,
i: this._keys.length - 1
}, this);
}, t.prototype.values = function() {
var e = this, t = 0;
return {
next: function() {
var n = e._keys[t++];
return {
value: void 0 !== n ? e._values[n].v : void 0,
done: void 0 === n
};
}
};
}, Object.defineProperty(t.prototype, "size", {
enumerable: !0,
get: function() {
return this._keys.length;
}
}), e.exports = t;
}
}), map_1 = map.Map;
long__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.toExtendedJSON = function(e) {
return e && e.relaxed ? this.toNumber() : {
$numberLong: this.toString()
};
}, long__WEBPACK_IMPORTED_MODULE_0___default.a.fromExtendedJSON = function(e, t) {
var n = long__WEBPACK_IMPORTED_MODULE_0___default.a.fromString(e.$numberLong);
return t && t.relaxed ? n.toNumber() : n;
}, Object.defineProperty(long__WEBPACK_IMPORTED_MODULE_0___default.a.prototype, "_bsontype", {
value: "Long"
});
var long_1 = long__WEBPACK_IMPORTED_MODULE_0___default.a;
function _classCallCheck(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties(e, t) {
for (var n = 0; n < t.length; n++) {
var r = t[n];
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), 
Object.defineProperty(e, r.key, r);
}
}
function _createClass(e, t, n) {
return t && _defineProperties(e.prototype, t), n && _defineProperties(e, n), e;
}
var Double = function() {
function e(t) {
_classCallCheck(this, e), t instanceof Number && (t = t.valueOf()), this.value = t;
}
return _createClass(e, [ {
key: "valueOf",
value: function() {
return this.value;
}
}, {
key: "toJSON",
value: function() {
return this.value;
}
}, {
key: "toExtendedJSON",
value: function(e) {
return e && (e.legacy || e.relaxed && isFinite(this.value)) ? this.value : Object.is(Math.sign(this.value), -0) ? {
$numberDouble: "-".concat(this.value.toFixed(1))
} : {
$numberDouble: Number.isInteger(this.value) ? this.value.toFixed(1) : this.value.toString()
};
}
} ], [ {
key: "fromExtendedJSON",
value: function(t, n) {
var r = parseFloat(t.$numberDouble);
return n && n.relaxed ? r : new e(r);
}
} ]), e;
}();
Object.defineProperty(Double.prototype, "_bsontype", {
value: "Double"
});
var double_1 = Double;
function _typeof(e) {
return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
return typeof e;
} : function(e) {
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
})(e);
}
function _classCallCheck$1(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties$1(e, t) {
for (var n = 0; n < t.length; n++) {
var r = t[n];
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), 
Object.defineProperty(e, r.key, r);
}
}
function _createClass$1(e, t, n) {
return t && _defineProperties$1(e.prototype, t), n && _defineProperties$1(e, n), 
e;
}
function _possibleConstructorReturn(e, t) {
return !t || "object" !== _typeof(t) && "function" != typeof t ? _assertThisInitialized(e) : t;
}
function _assertThisInitialized(e) {
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return e;
}
function _getPrototypeOf(e) {
return (_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function(e) {
return e.__proto__ || Object.getPrototypeOf(e);
})(e);
}
function _inherits(e, t) {
if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
e.prototype = Object.create(t && t.prototype, {
constructor: {
value: e,
writable: !0,
configurable: !0
}
}), t && _setPrototypeOf(e, t);
}
function _setPrototypeOf(e, t) {
return (_setPrototypeOf = Object.setPrototypeOf || function(e, t) {
return e.__proto__ = t, e;
})(e, t);
}
var Timestamp = function() {
function e(t, n) {
var r;
return _classCallCheck$1(this, e), r = long_1.isLong(t) ? _possibleConstructorReturn(this, _getPrototypeOf(e).call(this, t.low, t.high, !0)) : _possibleConstructorReturn(this, _getPrototypeOf(e).call(this, t, n, !0)), 
_possibleConstructorReturn(r);
}
return _inherits(e, long_1), _createClass$1(e, [ {
key: "toJSON",
value: function() {
return {
$timestamp: this.toString()
};
}
}, {
key: "toExtendedJSON",
value: function() {
return {
$timestamp: {
t: this.high >>> 0,
i: this.low >>> 0
}
};
}
} ], [ {
key: "fromInt",
value: function(t) {
return new e(long_1.fromInt(t, !0));
}
}, {
key: "fromNumber",
value: function(t) {
return new e(long_1.fromNumber(t, !0));
}
}, {
key: "fromBits",
value: function(t, n) {
return new e(t, n);
}
}, {
key: "fromString",
value: function(t, n) {
return new e(long_1.fromString(t, n, !0));
}
}, {
key: "fromExtendedJSON",
value: function(t) {
return new e(t.$timestamp.i, t.$timestamp.t);
}
} ]), e;
}();
Object.defineProperty(Timestamp.prototype, "_bsontype", {
value: "Timestamp"
}), Timestamp.MAX_VALUE = Timestamp.MAX_UNSIGNED_VALUE;
var timestamp = Timestamp, require$$0 = {};
function normalizedFunctionString(e) {
return e.toString().replace("function(", "function (");
}
function insecureRandomBytes(e) {
for (var t = new Uint8Array(e), n = 0; n < e; ++n) t[n] = Math.floor(256 * Math.random());
return t;
}
var randomBytes = insecureRandomBytes;
if ("undefined" != typeof window && window.crypto && window.crypto.getRandomValues) randomBytes = function(e) {
return window.crypto.getRandomValues(new Uint8Array(e));
}; else {
try {
randomBytes = require$$0.randomBytes;
} catch (e) {}
null == randomBytes && (randomBytes = insecureRandomBytes);
}
var utils = {
normalizedFunctionString: normalizedFunctionString,
randomBytes: randomBytes
};
function defaultSetTimout() {
throw new Error("setTimeout has not been defined");
}
function defaultClearTimeout() {
throw new Error("clearTimeout has not been defined");
}
var cachedSetTimeout = defaultSetTimout, cachedClearTimeout = defaultClearTimeout;
function runTimeout(e) {
if (cachedSetTimeout === setTimeout) return setTimeout(e, 0);
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) return cachedSetTimeout = setTimeout, 
setTimeout(e, 0);
try {
return cachedSetTimeout(e, 0);
} catch (t) {
try {
return cachedSetTimeout.call(null, e, 0);
} catch (t) {
return cachedSetTimeout.call(this, e, 0);
}
}
}
function runClearTimeout(e) {
if (cachedClearTimeout === clearTimeout) return clearTimeout(e);
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) return cachedClearTimeout = clearTimeout, 
clearTimeout(e);
try {
return cachedClearTimeout(e);
} catch (t) {
try {
return cachedClearTimeout.call(null, e);
} catch (t) {
return cachedClearTimeout.call(this, e);
}
}
}
"function" == typeof global.setTimeout && (cachedSetTimeout = setTimeout), "function" == typeof global.clearTimeout && (cachedClearTimeout = clearTimeout);
var queue = [], draining = !1, currentQueue, queueIndex = -1;
function cleanUpNextTick() {
draining && currentQueue && (draining = !1, currentQueue.length ? queue = currentQueue.concat(queue) : queueIndex = -1, 
queue.length && drainQueue());
}
function drainQueue() {
if (!draining) {
var e = runTimeout(cleanUpNextTick);
draining = !0;
for (var t = queue.length; t; ) {
for (currentQueue = queue, queue = []; ++queueIndex < t; ) currentQueue && currentQueue[queueIndex].run();
queueIndex = -1, t = queue.length;
}
currentQueue = null, draining = !1, runClearTimeout(e);
}
}
function nextTick(e) {
var t = new Array(arguments.length - 1);
if (arguments.length > 1) for (var n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
queue.push(new Item(e, t)), 1 !== queue.length || draining || runTimeout(drainQueue);
}
function Item(e, t) {
this.fun = e, this.array = t;
}
Item.prototype.run = function() {
this.fun.apply(null, this.array);
};
var title = "browser", platform = "browser", browser = !0, env = {}, argv = [], version = "", versions = {}, release = {}, config = {};
function noop() {}
var on = noop, addListener = noop, once = noop, off = noop, removeListener = noop, removeAllListeners = noop, emit = noop;
function binding() {
throw new Error("process.binding is not supported");
}
function cwd() {
return "/";
}
function chdir() {
throw new Error("process.chdir is not supported");
}
function umask() {
return 0;
}
var performance = global.performance || {}, performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function() {
return new Date().getTime();
};
function hrtime(e) {
var t = .001 * performanceNow.call(performance), n = Math.floor(t), r = Math.floor(t % 1 * 1e9);
return e && (n -= e[0], (r -= e[1]) < 0 && (n--, r += 1e9)), [ n, r ];
}
var startTime = new Date();
function uptime() {
return (new Date() - startTime) / 1e3;
}
var process = {
nextTick: nextTick,
title: title,
browser: browser,
env: env,
argv: argv,
version: version,
versions: versions,
on: on,
addListener: addListener,
once: once,
off: off,
removeListener: removeListener,
removeAllListeners: removeAllListeners,
emit: emit,
binding: binding,
cwd: cwd,
chdir: chdir,
umask: umask,
hrtime: hrtime,
platform: platform,
release: release,
config: config,
uptime: uptime
}, inherits;
inherits = "function" == typeof Object.create ? function(e, t) {
e.super_ = t, e.prototype = Object.create(t.prototype, {
constructor: {
value: e,
enumerable: !1,
writable: !0,
configurable: !0
}
});
} : function(e, t) {
e.super_ = t;
var n = function() {};
n.prototype = t.prototype, e.prototype = new n(), e.prototype.constructor = e;
};
var inherits$1 = inherits;
function _typeof$1(e) {
return (_typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
return typeof e;
} : function(e) {
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
})(e);
}
var formatRegExp = /%[sdj%]/g;
function format(e) {
if (!isString(e)) {
for (var t = [], n = 0; n < arguments.length; n++) t.push(inspect(arguments[n]));
return t.join(" ");
}
n = 1;
for (var r = arguments, i = r.length, o = String(e).replace(formatRegExp, function(e) {
if ("%%" === e) return "%";
if (n >= i) return e;
switch (e) {
case "%s":
return String(r[n++]);

case "%d":
return Number(r[n++]);

case "%j":
try {
return JSON.stringify(r[n++]);
} catch (e) {
return "[Circular]";
}

default:
return e;
}
}), s = r[n]; n < i; s = r[++n]) isNull(s) || !isObject(s) ? o += " " + s : o += " " + inspect(s);
return o;
}
function deprecate(e, t) {
if (isUndefined(global.process)) return function() {
return deprecate(e, t).apply(this, arguments);
};
var n = !1;
return function() {
return n || (console.error(t), n = !0), e.apply(this, arguments);
};
}
var debugs = {}, debugEnviron;
function debuglog(e) {
(isUndefined(debugEnviron) && (debugEnviron = process.env.NODE_DEBUG || ""), e = e.toUpperCase(), 
debugs[e]) || (new RegExp("\\b" + e + "\\b", "i").test(debugEnviron) ? debugs[e] = function() {
var t = format.apply(null, arguments);
console.error("%s %d: %s", e, 0, t);
} : debugs[e] = function() {});
return debugs[e];
}
function inspect(e, t) {
var n = {
seen: [],
stylize: stylizeNoColor
};
return arguments.length >= 3 && (n.depth = arguments[2]), arguments.length >= 4 && (n.colors = arguments[3]), 
isBoolean(t) ? n.showHidden = t : t && _extend(n, t), isUndefined(n.showHidden) && (n.showHidden = !1), 
isUndefined(n.depth) && (n.depth = 2), isUndefined(n.colors) && (n.colors = !1), 
isUndefined(n.customInspect) && (n.customInspect = !0), n.colors && (n.stylize = stylizeWithColor), 
formatValue(n, e, n.depth);
}
function stylizeWithColor(e, t) {
var n = inspect.styles[t];
return n ? "[" + inspect.colors[n][0] + "m" + e + "[" + inspect.colors[n][1] + "m" : e;
}
function stylizeNoColor(e) {
return e;
}
function arrayToHash(e) {
var t = {};
return e.forEach(function(e) {
t[e] = !0;
}), t;
}
function formatValue(e, t, n) {
if (e.customInspect && t && isFunction(t.inspect) && t.inspect !== inspect && (!t.constructor || t.constructor.prototype !== t)) {
var r = t.inspect(n, e);
return isString(r) || (r = formatValue(e, r, n)), r;
}
var i = formatPrimitive(e, t);
if (i) return i;
var o = Object.keys(t), s = arrayToHash(o);
if (e.showHidden && (o = Object.getOwnPropertyNames(t)), isError(t) && (o.indexOf("message") >= 0 || o.indexOf("description") >= 0)) return formatError(t);
if (0 === o.length) {
if (isFunction(t)) {
var a = t.name ? ": " + t.name : "";
return e.stylize("[Function" + a + "]", "special");
}
if (isRegExp(t)) return e.stylize(RegExp.prototype.toString.call(t), "regexp");
if (isDate(t)) return e.stylize(Date.prototype.toString.call(t), "date");
if (isError(t)) return formatError(t);
}
var u, c = "", f = !1, l = [ "{", "}" ];
(isArray(t) && (f = !0, l = [ "[", "]" ]), isFunction(t)) && (c = " [Function" + (t.name ? ": " + t.name : "") + "]");
return isRegExp(t) && (c = " " + RegExp.prototype.toString.call(t)), isDate(t) && (c = " " + Date.prototype.toUTCString.call(t)), 
isError(t) && (c = " " + formatError(t)), 0 !== o.length || f && 0 != t.length ? n < 0 ? isRegExp(t) ? e.stylize(RegExp.prototype.toString.call(t), "regexp") : e.stylize("[Object]", "special") : (e.seen.push(t), 
u = f ? formatArray(e, t, n, s, o) : o.map(function(r) {
return formatProperty(e, t, n, s, r, f);
}), e.seen.pop(), reduceToSingleString(u, c, l)) : l[0] + c + l[1];
}
function formatPrimitive(e, t) {
if (isUndefined(t)) return e.stylize("undefined", "undefined");
if (isString(t)) {
var n = "'" + JSON.stringify(t).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, '"') + "'";
return e.stylize(n, "string");
}
return isNumber(t) ? e.stylize("" + t, "number") : isBoolean(t) ? e.stylize("" + t, "boolean") : isNull(t) ? e.stylize("null", "null") : void 0;
}
function formatError(e) {
return "[" + Error.prototype.toString.call(e) + "]";
}
function formatArray(e, t, n, r, i) {
for (var o = [], s = 0, a = t.length; s < a; ++s) hasOwnProperty(t, String(s)) ? o.push(formatProperty(e, t, n, r, String(s), !0)) : o.push("");
return i.forEach(function(i) {
i.match(/^\d+$/) || o.push(formatProperty(e, t, n, r, i, !0));
}), o;
}
function formatProperty(e, t, n, r, i, o) {
var s, a, u;
if ((u = Object.getOwnPropertyDescriptor(t, i) || {
value: t[i]
}).get ? a = u.set ? e.stylize("[Getter/Setter]", "special") : e.stylize("[Getter]", "special") : u.set && (a = e.stylize("[Setter]", "special")), 
hasOwnProperty(r, i) || (s = "[" + i + "]"), a || (e.seen.indexOf(u.value) < 0 ? (a = isNull(n) ? formatValue(e, u.value, null) : formatValue(e, u.value, n - 1)).indexOf("\n") > -1 && (a = o ? a.split("\n").map(function(e) {
return "  " + e;
}).join("\n").substr(2) : "\n" + a.split("\n").map(function(e) {
return "   " + e;
}).join("\n")) : a = e.stylize("[Circular]", "special")), isUndefined(s)) {
if (o && i.match(/^\d+$/)) return a;
(s = JSON.stringify("" + i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/) ? (s = s.substr(1, s.length - 2), 
s = e.stylize(s, "name")) : (s = s.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"), 
s = e.stylize(s, "string"));
}
return s + ": " + a;
}
function reduceToSingleString(e, t, n) {
return e.reduce(function(e, t) {
return t.indexOf("\n"), e + t.replace(/\u001b\[\d\d?m/g, "").length + 1;
}, 0) > 60 ? n[0] + ("" === t ? "" : t + "\n ") + " " + e.join(",\n  ") + " " + n[1] : n[0] + t + " " + e.join(", ") + " " + n[1];
}
function isArray(e) {
return Array.isArray(e);
}
function isBoolean(e) {
return "boolean" == typeof e;
}
function isNull(e) {
return null === e;
}
function isNullOrUndefined(e) {
return null == e;
}
function isNumber(e) {
return "number" == typeof e;
}
function isString(e) {
return "string" == typeof e;
}
function isSymbol(e) {
return "symbol" === _typeof$1(e);
}
function isUndefined(e) {
return void 0 === e;
}
function isRegExp(e) {
return isObject(e) && "[object RegExp]" === objectToString(e);
}
function isObject(e) {
return "object" === _typeof$1(e) && null !== e;
}
function isDate(e) {
return isObject(e) && "[object Date]" === objectToString(e);
}
function isError(e) {
return isObject(e) && ("[object Error]" === objectToString(e) || e instanceof Error);
}
function isFunction(e) {
return "function" == typeof e;
}
function isPrimitive(e) {
return null === e || "boolean" == typeof e || "number" == typeof e || "string" == typeof e || "symbol" === _typeof$1(e) || void 0 === e;
}
function isBuffer(e) {
return Buffer.isBuffer(e);
}
function objectToString(e) {
return Object.prototype.toString.call(e);
}
function pad(e) {
return e < 10 ? "0" + e.toString(10) : e.toString(10);
}
inspect.colors = {
bold: [ 1, 22 ],
italic: [ 3, 23 ],
underline: [ 4, 24 ],
inverse: [ 7, 27 ],
white: [ 37, 39 ],
grey: [ 90, 39 ],
black: [ 30, 39 ],
blue: [ 34, 39 ],
cyan: [ 36, 39 ],
green: [ 32, 39 ],
magenta: [ 35, 39 ],
red: [ 31, 39 ],
yellow: [ 33, 39 ]
}, inspect.styles = {
special: "cyan",
number: "yellow",
boolean: "yellow",
undefined: "grey",
null: "bold",
string: "green",
date: "magenta",
regexp: "red"
};
var months = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
function timestamp$1() {
var e = new Date(), t = [ pad(e.getHours()), pad(e.getMinutes()), pad(e.getSeconds()) ].join(":");
return [ e.getDate(), months[e.getMonth()], t ].join(" ");
}
function log() {
console.log("%s - %s", timestamp$1(), format.apply(null, arguments));
}
function _extend(e, t) {
if (!t || !isObject(t)) return e;
for (var n = Object.keys(t), r = n.length; r--; ) e[n[r]] = t[n[r]];
return e;
}
function hasOwnProperty(e, t) {
return Object.prototype.hasOwnProperty.call(e, t);
}
var util = {
inherits: inherits$1,
_extend: _extend,
log: log,
isBuffer: isBuffer,
isPrimitive: isPrimitive,
isFunction: isFunction,
isError: isError,
isDate: isDate,
isObject: isObject,
isRegExp: isRegExp,
isUndefined: isUndefined,
isSymbol: isSymbol,
isString: isString,
isNumber: isNumber,
isNullOrUndefined: isNullOrUndefined,
isNull: isNull,
isBoolean: isBoolean,
isArray: isArray,
inspect: inspect,
deprecate: deprecate,
format: format,
debuglog: debuglog
};
function _classCallCheck$2(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties$2(e, t) {
for (var n = 0; n < t.length; n++) {
var r = t[n];
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), 
Object.defineProperty(e, r.key, r);
}
}
function _createClass$2(e, t, n) {
return t && _defineProperties$2(e.prototype, t), n && _defineProperties$2(e, n), 
e;
}
var Buffer$1 = buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer, randomBytes$1 = utils.randomBytes, deprecate$1 = util.deprecate, PROCESS_UNIQUE = randomBytes$1(5), checkForHexRegExp = new RegExp("^[0-9a-fA-F]{24}$"), hasBufferType = !1;
try {
Buffer$1 && Buffer$1.from && (hasBufferType = !0);
} catch (e) {
hasBufferType = !1;
}
for (var hexTable = [], _i = 0; _i < 256; _i++) hexTable[_i] = (_i <= 15 ? "0" : "") + _i.toString(16);
for (var decodeLookup = [], i = 0; i < 10; ) decodeLookup[48 + i] = i++;
for (;i < 16; ) decodeLookup[55 + i] = decodeLookup[87 + i] = i++;
var _Buffer = Buffer$1;
function convertToHex(e) {
return e.toString("hex");
}
function makeObjectIdError(e, t) {
var n = e[t];
return new TypeError('ObjectId string "'.concat(e, '" contains invalid character "').concat(n, '" with character code (').concat(e.charCodeAt(t), "). All character codes for a non-hex string must be less than 256."));
}
var ObjectId = function() {
function e(t) {
if (_classCallCheck$2(this, e), t instanceof e) return t;
if (null == t || "number" == typeof t) return this.id = e.generate(t), void (e.cacheHexString && (this.__id = this.toString("hex")));
var n = e.isValid(t);
if (!n && null != t) throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");
if (n && "string" == typeof t && 24 === t.length && hasBufferType) return new e(Buffer$1.from(t, "hex"));
if (n && "string" == typeof t && 24 === t.length) return e.createFromHexString(t);
if (null == t || 12 !== t.length) {
if (null != t && t.toHexString) return e.createFromHexString(t.toHexString());
throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");
}
this.id = t, e.cacheHexString && (this.__id = this.toString("hex"));
}
return _createClass$2(e, [ {
key: "toHexString",
value: function() {
if (e.cacheHexString && this.__id) return this.__id;
var t = "";
if (!this.id || !this.id.length) throw new TypeError("invalid ObjectId, ObjectId.id must be either a string or a Buffer, but is [" + JSON.stringify(this.id) + "]");
if (this.id instanceof _Buffer) return t = convertToHex(this.id), e.cacheHexString && (this.__id = t), 
t;
for (var n = 0; n < this.id.length; n++) {
var r = hexTable[this.id.charCodeAt(n)];
if ("string" != typeof r) throw makeObjectIdError(this.id, n);
t += r;
}
return e.cacheHexString && (this.__id = t), t;
}
}, {
key: "toString",
value: function(e) {
return this.id && this.id.copy ? this.id.toString("string" == typeof e ? e : "hex") : this.toHexString();
}
}, {
key: "toJSON",
value: function() {
return this.toHexString();
}
}, {
key: "equals",
value: function(t) {
return t instanceof e ? this.toString() === t.toString() : "string" == typeof t && e.isValid(t) && 12 === t.length && this.id instanceof _Buffer ? t === this.id.toString("binary") : "string" == typeof t && e.isValid(t) && 24 === t.length ? t.toLowerCase() === this.toHexString() : "string" == typeof t && e.isValid(t) && 12 === t.length ? t === this.id : !(null == t || !(t instanceof e || t.toHexString)) && t.toHexString() === this.toHexString();
}
}, {
key: "getTimestamp",
value: function() {
var e = new Date(), t = this.id.readUInt32BE(0);
return e.setTime(1e3 * Math.floor(t)), e;
}
}, {
key: "toExtendedJSON",
value: function() {
return this.toHexString ? {
$oid: this.toHexString()
} : {
$oid: this.toString("hex")
};
}
} ], [ {
key: "getInc",
value: function() {
return e.index = (e.index + 1) % 16777215;
}
}, {
key: "generate",
value: function(t) {
"number" != typeof t && (t = ~~(Date.now() / 1e3));
var n = e.getInc(), r = Buffer$1.alloc(12);
return r[3] = 255 & t, r[2] = t >> 8 & 255, r[1] = t >> 16 & 255, r[0] = t >> 24 & 255, 
r[4] = PROCESS_UNIQUE[0], r[5] = PROCESS_UNIQUE[1], r[6] = PROCESS_UNIQUE[2], r[7] = PROCESS_UNIQUE[3], 
r[8] = PROCESS_UNIQUE[4], r[11] = 255 & n, r[10] = n >> 8 & 255, r[9] = n >> 16 & 255, 
r;
}
}, {
key: "createPk",
value: function() {
return new e();
}
}, {
key: "createFromTime",
value: function(t) {
var n = Buffer$1.from([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]);
return n[3] = 255 & t, n[2] = t >> 8 & 255, n[1] = t >> 16 & 255, n[0] = t >> 24 & 255, 
new e(n);
}
}, {
key: "createFromHexString",
value: function(t) {
if (void 0 === t || null != t && 24 !== t.length) throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");
if (hasBufferType) return new e(Buffer$1.from(t, "hex"));
for (var n = new _Buffer(12), r = 0, i = 0; i < 24; ) n[r++] = decodeLookup[t.charCodeAt(i++)] << 4 | decodeLookup[t.charCodeAt(i++)];
return new e(n);
}
}, {
key: "isValid",
value: function(t) {
return null != t && ("number" == typeof t || ("string" == typeof t ? 12 === t.length || 24 === t.length && checkForHexRegExp.test(t) : t instanceof e || t instanceof _Buffer && 12 === t.length || !!t.toHexString && (12 === t.id.length || 24 === t.id.length && checkForHexRegExp.test(t.id))));
}
}, {
key: "fromExtendedJSON",
value: function(t) {
return new e(t.$oid);
}
} ]), e;
}();
ObjectId.get_inc = deprecate$1(function() {
return ObjectId.getInc();
}, "Please use the static `ObjectId.getInc()` instead"), ObjectId.prototype.get_inc = deprecate$1(function() {
return ObjectId.getInc();
}, "Please use the static `ObjectId.getInc()` instead"), ObjectId.prototype.getInc = deprecate$1(function() {
return ObjectId.getInc();
}, "Please use the static `ObjectId.getInc()` instead"), ObjectId.prototype.generate = deprecate$1(function(e) {
return ObjectId.generate(e);
}, "Please use the static `ObjectId.generate(time)` instead"), Object.defineProperty(ObjectId.prototype, "generationTime", {
enumerable: !0,
get: function() {
return this.id[3] | this.id[2] << 8 | this.id[1] << 16 | this.id[0] << 24;
},
set: function(e) {
this.id[3] = 255 & e, this.id[2] = e >> 8 & 255, this.id[1] = e >> 16 & 255, this.id[0] = e >> 24 & 255;
}
}), ObjectId.prototype[util.inspect.custom || "inspect"] = ObjectId.prototype.toString, 
ObjectId.index = ~~(16777215 * Math.random()), Object.defineProperty(ObjectId.prototype, "_bsontype", {
value: "ObjectID"
});
var objectid = ObjectId;
function _classCallCheck$3(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties$3(e, t) {
for (var n = 0; n < t.length; n++) {
var r = t[n];
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), 
Object.defineProperty(e, r.key, r);
}
}
function _createClass$3(e, t, n) {
return t && _defineProperties$3(e.prototype, t), n && _defineProperties$3(e, n), 
e;
}
function alphabetize(e) {
return e.split("").sort().join("");
}
var BSONRegExp = function() {
function e(t, n) {
_classCallCheck$3(this, e), this.pattern = t || "", this.options = n ? alphabetize(n) : "";
for (var r = 0; r < this.options.length; r++) if ("i" !== this.options[r] && "m" !== this.options[r] && "x" !== this.options[r] && "l" !== this.options[r] && "s" !== this.options[r] && "u" !== this.options[r]) throw new Error("The regular expression option [".concat(this.options[r], "] is not supported"));
}
return _createClass$3(e, [ {
key: "toExtendedJSON",
value: function(e) {
return (e = e || {}).legacy ? {
$regex: this.pattern,
$options: this.options
} : {
$regularExpression: {
pattern: this.pattern,
options: this.options
}
};
}
} ], [ {
key: "parseOptions",
value: function(e) {
return e ? e.split("").sort().join("") : "";
}
}, {
key: "fromExtendedJSON",
value: function(t) {
return t.$regex ? "BSONRegExp" === t.$regex._bsontype ? t : new e(t.$regex, e.parseOptions(t.$options)) : new e(t.$regularExpression.pattern, e.parseOptions(t.$regularExpression.options));
}
} ]), e;
}();
Object.defineProperty(BSONRegExp.prototype, "_bsontype", {
value: "BSONRegExp"
});
var regexp = BSONRegExp;
function _classCallCheck$4(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties$4(e, t) {
for (var n = 0; n < t.length; n++) {
var r = t[n];
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), 
Object.defineProperty(e, r.key, r);
}
}
function _createClass$4(e, t, n) {
return t && _defineProperties$4(e.prototype, t), n && _defineProperties$4(e, n), 
e;
}
var BSONSymbol = function() {
function e(t) {
_classCallCheck$4(this, e), this.value = t;
}
return _createClass$4(e, [ {
key: "valueOf",
value: function() {
return this.value;
}
}, {
key: "toString",
value: function() {
return this.value;
}
}, {
key: "inspect",
value: function() {
return this.value;
}
}, {
key: "toJSON",
value: function() {
return this.value;
}
}, {
key: "toExtendedJSON",
value: function() {
return {
$symbol: this.value
};
}
} ], [ {
key: "fromExtendedJSON",
value: function(t) {
return new e(t.$symbol);
}
} ]), e;
}();
Object.defineProperty(BSONSymbol.prototype, "_bsontype", {
value: "Symbol"
});
var symbol = BSONSymbol;
function _classCallCheck$5(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties$5(e, t) {
for (var n = 0; n < t.length; n++) {
var r = t[n];
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), 
Object.defineProperty(e, r.key, r);
}
}
function _createClass$5(e, t, n) {
return t && _defineProperties$5(e.prototype, t), n && _defineProperties$5(e, n), 
e;
}
var Int32 = function() {
function e(t) {
_classCallCheck$5(this, e), t instanceof Number && (t = t.valueOf()), this.value = t;
}
return _createClass$5(e, [ {
key: "valueOf",
value: function() {
return this.value;
}
}, {
key: "toJSON",
value: function() {
return this.value;
}
}, {
key: "toExtendedJSON",
value: function(e) {
return e && (e.relaxed || e.legacy) ? this.value : {
$numberInt: this.value.toString()
};
}
} ], [ {
key: "fromExtendedJSON",
value: function(t, n) {
return n && n.relaxed ? parseInt(t.$numberInt, 10) : new e(t.$numberInt);
}
} ]), e;
}();
Object.defineProperty(Int32.prototype, "_bsontype", {
value: "Int32"
});
var int_32 = Int32;
function _classCallCheck$6(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties$6(e, t) {
for (var n = 0; n < t.length; n++) {
var r = t[n];
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), 
Object.defineProperty(e, r.key, r);
}
}
function _createClass$6(e, t, n) {
return t && _defineProperties$6(e.prototype, t), n && _defineProperties$6(e, n), 
e;
}
var Code = function() {
function e(t, n) {
_classCallCheck$6(this, e), this.code = t, this.scope = n;
}
return _createClass$6(e, [ {
key: "toJSON",
value: function() {
return {
scope: this.scope,
code: this.code
};
}
}, {
key: "toExtendedJSON",
value: function() {
return this.scope ? {
$code: this.code,
$scope: this.scope
} : {
$code: this.code
};
}
} ], [ {
key: "fromExtendedJSON",
value: function(t) {
return new e(t.$code, t.$scope);
}
} ]), e;
}();
Object.defineProperty(Code.prototype, "_bsontype", {
value: "Code"
});
var code = Code, Buffer$2 = buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer, PARSE_STRING_REGEXP = /^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/, PARSE_INF_REGEXP = /^(\+|-)?(Infinity|inf)$/i, PARSE_NAN_REGEXP = /^(\+|-)?NaN$/i, EXPONENT_MAX = 6111, EXPONENT_MIN = -6176, EXPONENT_BIAS = 6176, MAX_DIGITS = 34, NAN_BUFFER = [ 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ].reverse(), INF_NEGATIVE_BUFFER = [ 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ].reverse(), INF_POSITIVE_BUFFER = [ 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ].reverse(), EXPONENT_REGEX = /^([-+])?(\d+)?$/;
function isDigit(e) {
return !isNaN(parseInt(e, 10));
}
function divideu128(e) {
var t = long_1.fromNumber(1e9), n = long_1.fromNumber(0);
if (!(e.parts[0] || e.parts[1] || e.parts[2] || e.parts[3])) return {
quotient: e,
rem: n
};
for (var r = 0; r <= 3; r++) n = (n = n.shiftLeft(32)).add(new long_1(e.parts[r], 0)), 
e.parts[r] = n.div(t).low, n = n.modulo(t);
return {
quotient: e,
rem: n
};
}
function multiply64x2(e, t) {
if (!e && !t) return {
high: long_1.fromNumber(0),
low: long_1.fromNumber(0)
};
var n = e.shiftRightUnsigned(32), r = new long_1(e.getLowBits(), 0), i = t.shiftRightUnsigned(32), o = new long_1(t.getLowBits(), 0), s = n.multiply(i), a = n.multiply(o), u = r.multiply(i), c = r.multiply(o);
return s = s.add(a.shiftRightUnsigned(32)), a = new long_1(a.getLowBits(), 0).add(u).add(c.shiftRightUnsigned(32)), 
{
high: s = s.add(a.shiftRightUnsigned(32)),
low: c = a.shiftLeft(32).add(new long_1(c.getLowBits(), 0))
};
}
function lessThan(e, t) {
var n = e.high >>> 0, r = t.high >>> 0;
return n < r || n === r && e.low >>> 0 < t.low >>> 0;
}
function invalidErr(e, t) {
throw new TypeError('"'.concat(e, '" is not a valid Decimal128 string - ').concat(t));
}
function Decimal128(e) {
this.bytes = e;
}
Decimal128.fromString = function(e) {
var t, n = !1, r = !1, i = !1, o = 0, s = 0, a = 0, u = 0, c = 0, f = [ 0 ], l = 0, h = 0, p = 0, d = 0, y = 0, _ = 0, g = [ 0, 0 ], v = [ 0, 0 ], m = 0;
if (e.length >= 7e3) throw new TypeError(e + " not a valid Decimal128 string");
var b = e.match(PARSE_STRING_REGEXP), w = e.match(PARSE_INF_REGEXP), E = e.match(PARSE_NAN_REGEXP);
if (!b && !w && !E || 0 === e.length) throw new TypeError(e + " not a valid Decimal128 string");
if (b) {
var S = b[2], A = b[4], O = b[5], I = b[6];
A && void 0 === I && invalidErr(e, "missing exponent power"), A && void 0 === S && invalidErr(e, "missing exponent base"), 
void 0 === A && (O || I) && invalidErr(e, "missing e before exponent");
}
if ("+" !== e[m] && "-" !== e[m] || (n = "-" === e[m++]), !isDigit(e[m]) && "." !== e[m]) {
if ("i" === e[m] || "I" === e[m]) return new Decimal128(Buffer$2.from(n ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
if ("N" === e[m]) return new Decimal128(Buffer$2.from(NAN_BUFFER));
}
for (;isDigit(e[m]) || "." === e[m]; ) "." !== e[m] ? (l < 34 && ("0" !== e[m] || i) && (i || (c = s), 
i = !0, f[h++] = parseInt(e[m], 10), l += 1), i && (a += 1), r && (u += 1), s += 1, 
m += 1) : (r && invalidErr(e, "contains multiple periods"), r = !0, m += 1);
if (r && !s) throw new TypeError(e + " not a valid Decimal128 string");
if ("e" === e[m] || "E" === e[m]) {
var T = e.substr(++m).match(EXPONENT_REGEX);
if (!T || !T[2]) return new Decimal128(Buffer$2.from(NAN_BUFFER));
y = parseInt(T[0], 10), m += T[0].length;
}
if (e[m]) return new Decimal128(Buffer$2.from(NAN_BUFFER));
if (p = 0, l) {
if (d = l - 1, 1 !== (o = a)) for (;"0" === e[c + o - 1]; ) o -= 1;
} else p = 0, d = 0, f[0] = 0, a = 1, l = 1, o = 0;
for (y <= u && u - y > 16384 ? y = EXPONENT_MIN : y -= u; y > EXPONENT_MAX; ) {
if ((d += 1) - p > MAX_DIGITS) {
if (f.join("").match(/^0+$/)) {
y = EXPONENT_MAX;
break;
}
invalidErr(e, "overflow");
}
y -= 1;
}
for (;y < EXPONENT_MIN || l < a; ) {
if (0 === d && o < l) {
y = EXPONENT_MIN, o = 0;
break;
}
if (l < a ? a -= 1 : d -= 1, y < EXPONENT_MAX) y += 1; else {
if (f.join("").match(/^0+$/)) {
y = EXPONENT_MAX;
break;
}
invalidErr(e, "overflow");
}
}
if (d - p + 1 < o) {
var N = s;
r && (c += 1, N += 1), n && (c += 1, N += 1);
var R = parseInt(e[c + d + 1], 10), P = 0;
if (R >= 5 && (P = 1, 5 === R)) for (P = f[d] % 2 == 1, _ = c + d + 2; _ < N; _++) if (parseInt(e[_], 10)) {
P = 1;
break;
}
if (P) for (var B = d; B >= 0; B--) if (++f[B] > 9 && (f[B] = 0, 0 === B)) {
if (!(y < EXPONENT_MAX)) return new Decimal128(Buffer$2.from(n ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
y += 1, f[B] = 1;
}
}
if (g = long_1.fromNumber(0), v = long_1.fromNumber(0), 0 === o) g = long_1.fromNumber(0), 
v = long_1.fromNumber(0); else if (d - p < 17) {
var D = p;
for (v = long_1.fromNumber(f[D++]), g = new long_1(0, 0); D <= d; D++) v = (v = v.multiply(long_1.fromNumber(10))).add(long_1.fromNumber(f[D]));
} else {
var C = p;
for (g = long_1.fromNumber(f[C++]); C <= d - 17; C++) g = (g = g.multiply(long_1.fromNumber(10))).add(long_1.fromNumber(f[C]));
for (v = long_1.fromNumber(f[C++]); C <= d; C++) v = (v = v.multiply(long_1.fromNumber(10))).add(long_1.fromNumber(f[C]));
}
var L = multiply64x2(g, long_1.fromString("100000000000000000"));
L.low = L.low.add(v), lessThan(L.low, v) && (L.high = L.high.add(long_1.fromNumber(1))), 
t = y + EXPONENT_BIAS;
var x = {
low: long_1.fromNumber(0),
high: long_1.fromNumber(0)
};
L.high.shiftRightUnsigned(49).and(long_1.fromNumber(1)).equals(long_1.fromNumber(1)) ? (x.high = x.high.or(long_1.fromNumber(3).shiftLeft(61)), 
x.high = x.high.or(long_1.fromNumber(t).and(long_1.fromNumber(16383).shiftLeft(47))), 
x.high = x.high.or(L.high.and(long_1.fromNumber(0x7fffffffffff)))) : (x.high = x.high.or(long_1.fromNumber(16383 & t).shiftLeft(49)), 
x.high = x.high.or(L.high.and(long_1.fromNumber(562949953421311)))), x.low = L.low, 
n && (x.high = x.high.or(long_1.fromString("9223372036854775808")));
var k = Buffer$2.alloc(16);
return m = 0, k[m++] = 255 & x.low.low, k[m++] = x.low.low >> 8 & 255, k[m++] = x.low.low >> 16 & 255, 
k[m++] = x.low.low >> 24 & 255, k[m++] = 255 & x.low.high, k[m++] = x.low.high >> 8 & 255, 
k[m++] = x.low.high >> 16 & 255, k[m++] = x.low.high >> 24 & 255, k[m++] = 255 & x.high.low, 
k[m++] = x.high.low >> 8 & 255, k[m++] = x.high.low >> 16 & 255, k[m++] = x.high.low >> 24 & 255, 
k[m++] = 255 & x.high.high, k[m++] = x.high.high >> 8 & 255, k[m++] = x.high.high >> 16 & 255, 
k[m++] = x.high.high >> 24 & 255, new Decimal128(k);
};
var COMBINATION_MASK = 31, EXPONENT_MASK = 16383, COMBINATION_INFINITY = 30, COMBINATION_NAN = 31;
Decimal128.prototype.toString = function() {
for (var e, t, n, r, i, o, s = 0, a = new Array(36), u = 0; u < a.length; u++) a[u] = 0;
var c, f, l, h, p, d = 0, y = !1, _ = {
parts: new Array(4)
}, g = [];
d = 0;
var v = this.bytes;
if (r = v[d++] | v[d++] << 8 | v[d++] << 16 | v[d++] << 24, n = v[d++] | v[d++] << 8 | v[d++] << 16 | v[d++] << 24, 
t = v[d++] | v[d++] << 8 | v[d++] << 16 | v[d++] << 24, e = v[d++] | v[d++] << 8 | v[d++] << 16 | v[d++] << 24, 
d = 0, (new long_1(r, n), new long_1(t, e)).lessThan(long_1.ZERO) && g.push("-"), 
(i = e >> 26 & COMBINATION_MASK) >> 3 == 3) {
if (i === COMBINATION_INFINITY) return g.join("") + "Infinity";
if (i === COMBINATION_NAN) return "NaN";
o = e >> 15 & EXPONENT_MASK, l = 8 + (e >> 14 & 1);
} else l = e >> 14 & 7, o = e >> 17 & EXPONENT_MASK;
if (c = o - EXPONENT_BIAS, _.parts[0] = (16383 & e) + ((15 & l) << 14), _.parts[1] = t, 
_.parts[2] = n, _.parts[3] = r, 0 === _.parts[0] && 0 === _.parts[1] && 0 === _.parts[2] && 0 === _.parts[3]) y = !0; else for (p = 3; p >= 0; p--) {
var m = 0, b = divideu128(_);
if (_ = b.quotient, m = b.rem.low) for (h = 8; h >= 0; h--) a[9 * p + h] = m % 10, 
m = Math.floor(m / 10);
}
if (y) s = 1, a[d] = 0; else for (s = 36; !a[d]; ) s -= 1, d += 1;
if ((f = s - 1 + c) >= 34 || f <= -7 || c > 0) {
if (s > 34) return g.push(0), c > 0 ? g.push("E+" + c) : c < 0 && g.push("E" + c), 
g.join("");
g.push(a[d++]), (s -= 1) && g.push(".");
for (var w = 0; w < s; w++) g.push(a[d++]);
g.push("E"), f > 0 ? g.push("+" + f) : g.push(f);
} else if (c >= 0) for (var E = 0; E < s; E++) g.push(a[d++]); else {
var S = s + c;
if (S > 0) for (var A = 0; A < S; A++) g.push(a[d++]); else g.push("0");
for (g.push("."); S++ < 0; ) g.push("0");
for (var O = 0; O < s - Math.max(S - 1, 0); O++) g.push(a[d++]);
}
return g.join("");
}, Decimal128.prototype.toJSON = function() {
return {
$numberDecimal: this.toString()
};
}, Decimal128.prototype.toExtendedJSON = function() {
return {
$numberDecimal: this.toString()
};
}, Decimal128.fromExtendedJSON = function(e) {
return Decimal128.fromString(e.$numberDecimal);
}, Object.defineProperty(Decimal128.prototype, "_bsontype", {
value: "Decimal128"
});
var decimal128 = Decimal128;
function _classCallCheck$7(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties$7(e, t) {
for (var n = 0; n < t.length; n++) {
var r = t[n];
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), 
Object.defineProperty(e, r.key, r);
}
}
function _createClass$7(e, t, n) {
return t && _defineProperties$7(e.prototype, t), n && _defineProperties$7(e, n), 
e;
}
var MinKey = function() {
function e() {
_classCallCheck$7(this, e);
}
return _createClass$7(e, [ {
key: "toExtendedJSON",
value: function() {
return {
$minKey: 1
};
}
} ], [ {
key: "fromExtendedJSON",
value: function() {
return new e();
}
} ]), e;
}();
Object.defineProperty(MinKey.prototype, "_bsontype", {
value: "MinKey"
});
var min_key = MinKey;
function _classCallCheck$8(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties$8(e, t) {
for (var n = 0; n < t.length; n++) {
var r = t[n];
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), 
Object.defineProperty(e, r.key, r);
}
}
function _createClass$8(e, t, n) {
return t && _defineProperties$8(e.prototype, t), n && _defineProperties$8(e, n), 
e;
}
var MaxKey = function() {
function e() {
_classCallCheck$8(this, e);
}
return _createClass$8(e, [ {
key: "toExtendedJSON",
value: function() {
return {
$maxKey: 1
};
}
} ], [ {
key: "fromExtendedJSON",
value: function() {
return new e();
}
} ]), e;
}();
Object.defineProperty(MaxKey.prototype, "_bsontype", {
value: "MaxKey"
});
var max_key = MaxKey;
function _classCallCheck$9(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties$9(e, t) {
for (var n = 0; n < t.length; n++) {
var r = t[n];
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), 
Object.defineProperty(e, r.key, r);
}
}
function _createClass$9(e, t, n) {
return t && _defineProperties$9(e.prototype, t), n && _defineProperties$9(e, n), 
e;
}
var DBRef = function() {
function e(t, n, r, i) {
_classCallCheck$9(this, e);
var o = t.split(".");
2 === o.length && (r = o.shift(), t = o.shift()), this.collection = t, this.oid = n, 
this.db = r, this.fields = i || {};
}
return _createClass$9(e, [ {
key: "toJSON",
value: function() {
var e = Object.assign({
$ref: this.collection,
$id: this.oid
}, this.fields);
return null != this.db && (e.$db = this.db), e;
}
}, {
key: "toExtendedJSON",
value: function(e) {
e = e || {};
var t = {
$ref: this.collection,
$id: this.oid
};
return e.legacy ? t : (this.db && (t.$db = this.db), t = Object.assign(t, this.fields));
}
} ], [ {
key: "fromExtendedJSON",
value: function(t) {
var n = Object.assign({}, t);
return [ "$ref", "$id", "$db" ].forEach(function(e) {
return delete n[e];
}), new e(t.$ref, t.$id, t.$db, n);
}
} ]), e;
}();
Object.defineProperty(DBRef.prototype, "_bsontype", {
value: "DBRef"
}), Object.defineProperty(DBRef.prototype, "namespace", {
get: function() {
return this.collection;
},
set: function(e) {
this.collection = e;
},
configurable: !1
});
var db_ref = DBRef;
function _classCallCheck$a(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties$a(e, t) {
for (var n = 0; n < t.length; n++) {
var r = t[n];
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), 
Object.defineProperty(e, r.key, r);
}
}
function _createClass$a(e, t, n) {
return t && _defineProperties$a(e.prototype, t), n && _defineProperties$a(e, n), 
e;
}
var Buffer$3 = buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer, Binary = function() {
function e(t, n) {
if (_classCallCheck$a(this, e), !(null == t || "string" == typeof t || Buffer$3.isBuffer(t) || t instanceof Uint8Array || Array.isArray(t))) throw new TypeError("only String, Buffer, Uint8Array or Array accepted");
if (this.sub_type = null == n ? BSON_BINARY_SUBTYPE_DEFAULT : n, this.position = 0, 
null == t || t instanceof Number) void 0 !== Buffer$3 ? this.buffer = Buffer$3.alloc(e.BUFFER_SIZE) : "undefined" != typeof Uint8Array ? this.buffer = new Uint8Array(new ArrayBuffer(e.BUFFER_SIZE)) : this.buffer = new Array(e.BUFFER_SIZE); else {
if ("string" == typeof t) if (void 0 !== Buffer$3) this.buffer = Buffer$3.from(t); else {
if ("undefined" == typeof Uint8Array && !Array.isArray(t)) throw new TypeError("only String, Buffer, Uint8Array or Array accepted");
this.buffer = writeStringToArray(t);
} else this.buffer = t;
this.position = t.length;
}
}
return _createClass$a(e, [ {
key: "put",
value: function(t) {
if (null != t.length && "number" != typeof t && 1 !== t.length) throw new TypeError("only accepts single character String, Uint8Array or Array");
if ("number" != typeof t && t < 0 || t > 255) throw new TypeError("only accepts number in a valid unsigned byte range 0-255");
var n;
if (n = "string" == typeof t ? t.charCodeAt(0) : null != t.length ? t[0] : t, this.buffer.length > this.position) this.buffer[this.position++] = n; else if (void 0 !== Buffer$3 && Buffer$3.isBuffer(this.buffer)) {
var r = Buffer$3.alloc(e.BUFFER_SIZE + this.buffer.length);
this.buffer.copy(r, 0, 0, this.buffer.length), this.buffer = r, this.buffer[this.position++] = n;
} else {
var i = null;
i = isUint8Array(this.buffer) ? new Uint8Array(new ArrayBuffer(e.BUFFER_SIZE + this.buffer.length)) : new Array(e.BUFFER_SIZE + this.buffer.length);
for (var o = 0; o < this.buffer.length; o++) i[o] = this.buffer[o];
this.buffer = i, this.buffer[this.position++] = n;
}
}
}, {
key: "write",
value: function(e, t) {
if (t = "number" == typeof t ? t : this.position, this.buffer.length < t + e.length) {
var n = null;
if (void 0 !== Buffer$3 && Buffer$3.isBuffer(this.buffer)) n = Buffer$3.alloc(this.buffer.length + e.length), 
this.buffer.copy(n, 0, 0, this.buffer.length); else if (isUint8Array(this.buffer)) {
n = new Uint8Array(new ArrayBuffer(this.buffer.length + e.length));
for (var r = 0; r < this.position; r++) n[r] = this.buffer[r];
}
this.buffer = n;
}
if (void 0 !== Buffer$3 && Buffer$3.isBuffer(e) && Buffer$3.isBuffer(this.buffer)) e.copy(this.buffer, t, 0, e.length), 
this.position = t + e.length > this.position ? t + e.length : this.position; else if (void 0 !== Buffer$3 && "string" == typeof e && Buffer$3.isBuffer(this.buffer)) this.buffer.write(e, t, "binary"), 
this.position = t + e.length > this.position ? t + e.length : this.position; else if (isUint8Array(e) || Array.isArray(e) && "string" != typeof e) {
for (var i = 0; i < e.length; i++) this.buffer[t++] = e[i];
this.position = t > this.position ? t : this.position;
} else if ("string" == typeof e) {
for (var o = 0; o < e.length; o++) this.buffer[t++] = e.charCodeAt(o);
this.position = t > this.position ? t : this.position;
}
}
}, {
key: "read",
value: function(e, t) {
if (t = t && t > 0 ? t : this.position, this.buffer.slice) return this.buffer.slice(e, e + t);
for (var n = "undefined" != typeof Uint8Array ? new Uint8Array(new ArrayBuffer(t)) : new Array(t), r = 0; r < t; r++) n[r] = this.buffer[e++];
return n;
}
}, {
key: "value",
value: function(e) {
if ((e = null != e && e) && void 0 !== Buffer$3 && Buffer$3.isBuffer(this.buffer) && this.buffer.length === this.position) return this.buffer;
if (void 0 !== Buffer$3 && Buffer$3.isBuffer(this.buffer)) return e ? this.buffer.slice(0, this.position) : this.buffer.toString("binary", 0, this.position);
if (e) {
if (null != this.buffer.slice) return this.buffer.slice(0, this.position);
for (var t = isUint8Array(this.buffer) ? new Uint8Array(new ArrayBuffer(this.position)) : new Array(this.position), n = 0; n < this.position; n++) t[n] = this.buffer[n];
return t;
}
return convertArraytoUtf8BinaryString(this.buffer, 0, this.position);
}
}, {
key: "length",
value: function() {
return this.position;
}
}, {
key: "toJSON",
value: function() {
return null != this.buffer ? this.buffer.toString("base64") : "";
}
}, {
key: "toString",
value: function(e) {
return null != this.buffer ? this.buffer.slice(0, this.position).toString(e) : "";
}
}, {
key: "toExtendedJSON",
value: function(e) {
e = e || {};
var t = Buffer$3.isBuffer(this.buffer) ? this.buffer.toString("base64") : Buffer$3.from(this.buffer).toString("base64"), n = Number(this.sub_type).toString(16);
return e.legacy ? {
$binary: t,
$type: 1 === n.length ? "0" + n : n
} : {
$binary: {
base64: t,
subType: 1 === n.length ? "0" + n : n
}
};
}
} ], [ {
key: "fromExtendedJSON",
value: function(t, n) {
var r, i;
return (n = n || {}).legacy ? (i = t.$type ? parseInt(t.$type, 16) : 0, r = Buffer$3.from(t.$binary, "base64")) : (i = t.$binary.subType ? parseInt(t.$binary.subType, 16) : 0, 
r = Buffer$3.from(t.$binary.base64, "base64")), new e(r, i);
}
} ]), e;
}(), BSON_BINARY_SUBTYPE_DEFAULT = 0;
function isUint8Array(e) {
return "[object Uint8Array]" === Object.prototype.toString.call(e);
}
function writeStringToArray(e) {
for (var t = "undefined" != typeof Uint8Array ? new Uint8Array(new ArrayBuffer(e.length)) : new Array(e.length), n = 0; n < e.length; n++) t[n] = e.charCodeAt(n);
return t;
}
function convertArraytoUtf8BinaryString(e, t, n) {
for (var r = "", i = t; i < n; i++) r += String.fromCharCode(e[i]);
return r;
}
Binary.BUFFER_SIZE = 256, Binary.SUBTYPE_DEFAULT = 0, Binary.SUBTYPE_FUNCTION = 1, 
Binary.SUBTYPE_BYTE_ARRAY = 2, Binary.SUBTYPE_UUID_OLD = 3, Binary.SUBTYPE_UUID = 4, 
Binary.SUBTYPE_MD5 = 5, Binary.SUBTYPE_USER_DEFINED = 128, Object.defineProperty(Binary.prototype, "_bsontype", {
value: "Binary"
});
var binary = Binary, constants = {
BSON_INT32_MAX: 2147483647,
BSON_INT32_MIN: -2147483648,
BSON_INT64_MAX: Math.pow(2, 63) - 1,
BSON_INT64_MIN: -Math.pow(2, 63),
JS_INT_MAX: 9007199254740992,
JS_INT_MIN: -9007199254740992,
BSON_DATA_NUMBER: 1,
BSON_DATA_STRING: 2,
BSON_DATA_OBJECT: 3,
BSON_DATA_ARRAY: 4,
BSON_DATA_BINARY: 5,
BSON_DATA_UNDEFINED: 6,
BSON_DATA_OID: 7,
BSON_DATA_BOOLEAN: 8,
BSON_DATA_DATE: 9,
BSON_DATA_NULL: 10,
BSON_DATA_REGEXP: 11,
BSON_DATA_DBPOINTER: 12,
BSON_DATA_CODE: 13,
BSON_DATA_SYMBOL: 14,
BSON_DATA_CODE_W_SCOPE: 15,
BSON_DATA_INT: 16,
BSON_DATA_TIMESTAMP: 17,
BSON_DATA_LONG: 18,
BSON_DATA_DECIMAL128: 19,
BSON_DATA_MIN_KEY: 255,
BSON_DATA_MAX_KEY: 127,
BSON_BINARY_SUBTYPE_DEFAULT: 0,
BSON_BINARY_SUBTYPE_FUNCTION: 1,
BSON_BINARY_SUBTYPE_BYTE_ARRAY: 2,
BSON_BINARY_SUBTYPE_UUID: 3,
BSON_BINARY_SUBTYPE_MD5: 4,
BSON_BINARY_SUBTYPE_USER_DEFINED: 128
};
function _typeof$2(e) {
return (_typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
return typeof e;
} : function(e) {
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
})(e);
}
var keysToCodecs = {
$oid: objectid,
$binary: binary,
$symbol: symbol,
$numberInt: int_32,
$numberDecimal: decimal128,
$numberDouble: double_1,
$numberLong: long_1,
$minKey: min_key,
$maxKey: max_key,
$regex: regexp,
$regularExpression: regexp,
$timestamp: timestamp
};
function deserializeValue(e, t, n, r) {
if ("number" == typeof n) {
if (r.relaxed || r.legacy) return n;
if (Math.floor(n) === n) {
if (n >= BSON_INT32_MIN && n <= BSON_INT32_MAX) return new int_32(n);
if (n >= BSON_INT64_MIN && n <= BSON_INT64_MAX) return new long_1.fromNumber(n);
}
return new double_1(n);
}
if (null == n || "object" !== _typeof$2(n)) return n;
if (n.$undefined) return null;
for (var i = Object.keys(n).filter(function(e) {
return e.startsWith("$") && null != n[e];
}), o = 0; o < i.length; o++) {
var s = keysToCodecs[i[o]];
if (s) return s.fromExtendedJSON(n, r);
}
if (null != n.$date) {
var a = n.$date, u = new Date();
return r.legacy ? "number" == typeof a ? u.setTime(a) : "string" == typeof a && u.setTime(Date.parse(a)) : "string" == typeof a ? u.setTime(Date.parse(a)) : long_1.isLong(a) ? u.setTime(a.toNumber()) : "number" == typeof a && r.relaxed && u.setTime(a), 
u;
}
if (null != n.$code) {
var c = Object.assign({}, n);
return n.$scope && (c.$scope = deserializeValue(e, null, n.$scope)), code.fromExtendedJSON(n);
}
if (null != n.$ref || null != n.$dbPointer) {
var f = n.$ref ? n : n.$dbPointer;
if (f instanceof db_ref) return f;
var l = Object.keys(f).filter(function(e) {
return e.startsWith("$");
}), h = !0;
if (l.forEach(function(e) {
-1 === [ "$ref", "$id", "$db" ].indexOf(e) && (h = !1);
}), h) return db_ref.fromExtendedJSON(f);
}
return n;
}
function parse(e, t) {
var n = this;
return "boolean" == typeof (t = Object.assign({}, {
relaxed: !0,
legacy: !1
}, t)).relaxed && (t.strict = !t.relaxed), "boolean" == typeof t.strict && (t.relaxed = !t.strict), 
JSON.parse(e, function(e, r) {
return deserializeValue(n, e, r, t);
});
}
var BSON_INT32_MAX = 2147483647, BSON_INT32_MIN = -2147483648, BSON_INT64_MAX = 0x8000000000000000, BSON_INT64_MIN = -0x8000000000000000;
function stringify(e, t, n, r) {
null != n && "object" === _typeof$2(n) && (r = n, n = 0), null == t || "object" !== _typeof$2(t) || Array.isArray(t) || (r = t, 
t = null, n = 0), r = Object.assign({}, {
relaxed: !0,
legacy: !1
}, r);
var i = Array.isArray(e) ? serializeArray(e, r) : serializeDocument(e, r);
return JSON.stringify(i, t, n);
}
function serialize(e, t) {
return t = t || {}, JSON.parse(stringify(e, t));
}
function deserialize(e, t) {
return t = t || {}, parse(JSON.stringify(e), t);
}
function serializeArray(e, t) {
return e.map(function(e) {
return serializeValue(e, t);
});
}
function getISOString(e) {
var t = e.toISOString();
return 0 !== e.getUTCMilliseconds() ? t : t.slice(0, -5) + "Z";
}
function serializeValue(e, t) {
if (Array.isArray(e)) return serializeArray(e, t);
if (void 0 === e) return null;
if (e instanceof Date) {
var n = e.getTime(), r = n > -1 && n < 2534023188e5;
return t.legacy ? t.relaxed && r ? {
$date: e.getTime()
} : {
$date: getISOString(e)
} : t.relaxed && r ? {
$date: getISOString(e)
} : {
$date: {
$numberLong: e.getTime().toString()
}
};
}
if ("number" == typeof e && !t.relaxed) {
if (Math.floor(e) === e) {
var i = e >= BSON_INT64_MIN && e <= BSON_INT64_MAX;
if (e >= BSON_INT32_MIN && e <= BSON_INT32_MAX) return {
$numberInt: e.toString()
};
if (i) return {
$numberLong: e.toString()
};
}
return {
$numberDouble: e.toString()
};
}
if (e instanceof RegExp) {
var o = e.flags;
return void 0 === o && (o = e.toString().match(/[gimuy]*$/)[0]), new regexp(e.source, o).toExtendedJSON(t);
}
return null != e && "object" === _typeof$2(e) ? serializeDocument(e, t) : e;
}
var BSON_TYPE_MAPPINGS = {
Binary: function(e) {
return new binary(e.value(), e.subtype);
},
Code: function(e) {
return new code(e.code, e.scope);
},
DBRef: function(e) {
return new db_ref(e.collection || e.namespace, e.oid, e.db, e.fields);
},
Decimal128: function(e) {
return new decimal128(e.bytes);
},
Double: function(e) {
return new double_1(e.value);
},
Int32: function(e) {
return new int_32(e.value);
},
Long: function(e) {
return long_1.fromBits(null != e.low ? e.low : e.low_, null != e.low ? e.high : e.high_, null != e.low ? e.unsigned : e.unsigned_);
},
MaxKey: function() {
return new max_key();
},
MinKey: function() {
return new min_key();
},
ObjectID: function(e) {
return new objectid(e);
},
ObjectId: function(e) {
return new objectid(e);
},
BSONRegExp: function(e) {
return new regexp(e.pattern, e.options);
},
Symbol: function(e) {
return new symbol(e.value);
},
Timestamp: function(e) {
return timestamp.fromBits(e.low, e.high);
}
};
function serializeDocument(e, t) {
if (null == e || "object" !== _typeof$2(e)) throw new Error("not an object instance");
var n = e._bsontype;
if (void 0 === n) {
var r = {};
for (var i in e) r[i] = serializeValue(e[i], t);
return r;
}
if ("string" == typeof n) {
var o = e;
if ("function" != typeof o.toExtendedJSON) {
var s = BSON_TYPE_MAPPINGS[n];
if (!s) throw new TypeError("Unrecognized or invalid _bsontype: " + n);
o = s(o);
}
return "Code" === n && o.scope ? o = new code(o.code, serializeValue(o.scope, t)) : "DBRef" === n && o.oid && (o = new db_ref(o.collection, serializeValue(o.oid, t), o.db, o.fields)), 
o.toExtendedJSON(t);
}
throw new Error("_bsontype must be a string, but was: " + _typeof$2(n));
}
var extended_json = {
parse: parse,
deserialize: deserialize,
serialize: serialize,
stringify: stringify
}, FIRST_BIT = 128, FIRST_TWO_BITS = 192, FIRST_THREE_BITS = 224, FIRST_FOUR_BITS = 240, FIRST_FIVE_BITS = 248, TWO_BIT_CHAR = 192, THREE_BIT_CHAR = 224, FOUR_BIT_CHAR = 240, CONTINUING_CHAR = 128;
function validateUtf8(e, t, n) {
for (var r = 0, i = t; i < n; i += 1) {
var o = e[i];
if (r) {
if ((o & FIRST_TWO_BITS) !== CONTINUING_CHAR) return !1;
r -= 1;
} else if (o & FIRST_BIT) if ((o & FIRST_THREE_BITS) === TWO_BIT_CHAR) r = 1; else if ((o & FIRST_FOUR_BITS) === THREE_BIT_CHAR) r = 2; else {
if ((o & FIRST_FIVE_BITS) !== FOUR_BIT_CHAR) return !1;
r = 3;
}
}
return !r;
}
var validateUtf8_1 = validateUtf8, validate_utf8 = {
validateUtf8: validateUtf8_1
}, Buffer$4 = buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer, validateUtf8$1 = validate_utf8.validateUtf8, JS_INT_MAX_LONG = long_1.fromNumber(constants.JS_INT_MAX), JS_INT_MIN_LONG = long_1.fromNumber(constants.JS_INT_MIN), functionCache = {};
function deserialize$1(e, t, n) {
var r = (t = null == t ? {} : t) && t.index ? t.index : 0, i = e[r] | e[r + 1] << 8 | e[r + 2] << 16 | e[r + 3] << 24;
if (i < 5) throw new Error("bson size must be >= 5, is ".concat(i));
if (t.allowObjectSmallerThanBufferSize && e.length < i) throw new Error("buffer length ".concat(e.length, " must be >= bson size ").concat(i));
if (!t.allowObjectSmallerThanBufferSize && e.length !== i) throw new Error("buffer length ".concat(e.length, " must === bson size ").concat(i));
if (i + r > e.length) throw new Error("(bson size ".concat(i, " + options.index ").concat(r, " must be <= buffer length ").concat(Buffer$4.byteLength(e), ")"));
if (0 !== e[r + i - 1]) throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");
return deserializeObject(e, r, t, n);
}
function deserializeObject(e, t, n, r) {
var i = null != n.evalFunctions && n.evalFunctions, o = null != n.cacheFunctions && n.cacheFunctions, s = null != n.cacheFunctionsCrc32 && n.cacheFunctionsCrc32;
if (!s) var a = null;
var u = null == n.fieldsAsRaw ? null : n.fieldsAsRaw, c = null != n.raw && n.raw, f = "boolean" == typeof n.bsonRegExp && n.bsonRegExp, l = null != n.promoteBuffers && n.promoteBuffers, h = null == n.promoteLongs || n.promoteLongs, p = null == n.promoteValues || n.promoteValues, d = t;
if (e.length < 5) throw new Error("corrupt bson message < 5 bytes long");
var y = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
if (y < 5 || y > e.length) throw new Error("corrupt bson message");
for (var _ = r ? [] : {}, g = 0; ;) {
var v = e[t++];
if (0 === v) break;
for (var m = t; 0 !== e[m] && m < e.length; ) m++;
if (m >= Buffer$4.byteLength(e)) throw new Error("Bad BSON Document: illegal CString");
var b = r ? g++ : e.toString("utf8", t, m);
if (t = m + 1, v === constants.BSON_DATA_STRING) {
var w = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
if (w <= 0 || w > e.length - t || 0 !== e[t + w - 1]) throw new Error("bad string length in bson");
if (!validateUtf8$1(e, t, t + w - 1)) throw new Error("Invalid UTF-8 string in BSON document");
var E = e.toString("utf8", t, t + w - 1);
_[b] = E, t += w;
} else if (v === constants.BSON_DATA_OID) {
var S = Buffer$4.alloc(12);
e.copy(S, 0, t, t + 12), _[b] = new objectid(S), t += 12;
} else if (v === constants.BSON_DATA_INT && !1 === p) _[b] = new int_32(e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24); else if (v === constants.BSON_DATA_INT) _[b] = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24; else if (v === constants.BSON_DATA_NUMBER && !1 === p) _[b] = new double_1(e.readDoubleLE(t)), 
t += 8; else if (v === constants.BSON_DATA_NUMBER) _[b] = e.readDoubleLE(t), t += 8; else if (v === constants.BSON_DATA_DATE) {
var A = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24, O = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
_[b] = new Date(new long_1(A, O).toNumber());
} else if (v === constants.BSON_DATA_BOOLEAN) {
if (0 !== e[t] && 1 !== e[t]) throw new Error("illegal boolean type value");
_[b] = 1 === e[t++];
} else if (v === constants.BSON_DATA_OBJECT) {
var I = t, T = e[t] | e[t + 1] << 8 | e[t + 2] << 16 | e[t + 3] << 24;
if (T <= 0 || T > e.length - t) throw new Error("bad embedded document length in bson");
_[b] = c ? e.slice(t, t + T) : deserializeObject(e, I, n, !1), t += T;
} else if (v === constants.BSON_DATA_ARRAY) {
var N = t, R = e[t] | e[t + 1] << 8 | e[t + 2] << 16 | e[t + 3] << 24, P = n, B = t + R;
if (u && u[b]) {
for (var D in P = {}, n) P[D] = n[D];
P.raw = !0;
}
if (_[b] = deserializeObject(e, N, P, !0), 0 !== e[(t += R) - 1]) throw new Error("invalid array terminator byte");
if (t !== B) throw new Error("corrupted array bson");
} else if (v === constants.BSON_DATA_UNDEFINED) _[b] = void 0; else if (v === constants.BSON_DATA_NULL) _[b] = null; else if (v === constants.BSON_DATA_LONG) {
var C = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24, L = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24, x = new long_1(C, L);
_[b] = h && !0 === p && x.lessThanOrEqual(JS_INT_MAX_LONG) && x.greaterThanOrEqual(JS_INT_MIN_LONG) ? x.toNumber() : x;
} else if (v === constants.BSON_DATA_DECIMAL128) {
var k = Buffer$4.alloc(16);
e.copy(k, 0, t, t + 16), t += 16;
var U = new decimal128(k);
_[b] = U.toObject ? U.toObject() : U;
} else if (v === constants.BSON_DATA_BINARY) {
var M = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24, j = M, $ = e[t++];
if (M < 0) throw new Error("Negative binary type element size found");
if (M > Buffer$4.byteLength(e)) throw new Error("Binary type size larger than document size");
if (null != e.slice) {
if ($ === binary.SUBTYPE_BYTE_ARRAY) {
if ((M = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24) < 0) throw new Error("Negative binary type element size found for subtype 0x02");
if (M > j - 4) throw new Error("Binary type with subtype 0x02 contains to long binary size");
if (M < j - 4) throw new Error("Binary type with subtype 0x02 contains to short binary size");
}
_[b] = l && p ? e.slice(t, t + M) : new binary(e.slice(t, t + M), $);
} else {
var q = "undefined" != typeof Uint8Array ? new Uint8Array(new ArrayBuffer(M)) : new Array(M);
if ($ === binary.SUBTYPE_BYTE_ARRAY) {
if ((M = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24) < 0) throw new Error("Negative binary type element size found for subtype 0x02");
if (M > j - 4) throw new Error("Binary type with subtype 0x02 contains to long binary size");
if (M < j - 4) throw new Error("Binary type with subtype 0x02 contains to short binary size");
}
for (m = 0; m < M; m++) q[m] = e[t + m];
_[b] = l && p ? q : new binary(q, $);
}
t += M;
} else if (v === constants.BSON_DATA_REGEXP && !1 === f) {
for (m = t; 0 !== e[m] && m < e.length; ) m++;
if (m >= e.length) throw new Error("Bad BSON Document: illegal CString");
var F = e.toString("utf8", t, m);
for (m = t = m + 1; 0 !== e[m] && m < e.length; ) m++;
if (m >= e.length) throw new Error("Bad BSON Document: illegal CString");
var W = e.toString("utf8", t, m);
t = m + 1;
var z = new Array(W.length);
for (m = 0; m < W.length; m++) switch (W[m]) {
case "m":
z[m] = "m";
break;

case "s":
z[m] = "g";
break;

case "i":
z[m] = "i";
}
_[b] = new RegExp(F, z.join(""));
} else if (v === constants.BSON_DATA_REGEXP && !0 === f) {
for (m = t; 0 !== e[m] && m < e.length; ) m++;
if (m >= e.length) throw new Error("Bad BSON Document: illegal CString");
var K = e.toString("utf8", t, m);
for (m = t = m + 1; 0 !== e[m] && m < e.length; ) m++;
if (m >= e.length) throw new Error("Bad BSON Document: illegal CString");
var G = e.toString("utf8", t, m);
t = m + 1, _[b] = new regexp(K, G);
} else if (v === constants.BSON_DATA_SYMBOL) {
var Y = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
if (Y <= 0 || Y > e.length - t || 0 !== e[t + Y - 1]) throw new Error("bad string length in bson");
var H = e.toString("utf8", t, t + Y - 1);
_[b] = p ? H : new symbol(H), t += Y;
} else if (v === constants.BSON_DATA_TIMESTAMP) {
var J = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24, V = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
_[b] = new timestamp(J, V);
} else if (v === constants.BSON_DATA_MIN_KEY) _[b] = new min_key(); else if (v === constants.BSON_DATA_MAX_KEY) _[b] = new max_key(); else if (v === constants.BSON_DATA_CODE) {
var X = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
if (X <= 0 || X > e.length - t || 0 !== e[t + X - 1]) throw new Error("bad string length in bson");
var Q = e.toString("utf8", t, t + X - 1);
if (i) if (o) {
var Z = s ? a(Q) : Q;
_[b] = isolateEvalWithHash(functionCache, Z, Q, _);
} else _[b] = isolateEval(Q); else _[b] = new code(Q);
t += X;
} else if (v === constants.BSON_DATA_CODE_W_SCOPE) {
var ee = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
if (ee < 13) throw new Error("code_w_scope total size shorter minimum expected length");
var te = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
if (te <= 0 || te > e.length - t || 0 !== e[t + te - 1]) throw new Error("bad string length in bson");
var ne = e.toString("utf8", t, t + te - 1), re = t += te, ie = e[t] | e[t + 1] << 8 | e[t + 2] << 16 | e[t + 3] << 24, oe = deserializeObject(e, re, n, !1);
if (t += ie, ee < 8 + ie + te) throw new Error("code_w_scope total size is to short, truncating scope");
if (ee > 8 + ie + te) throw new Error("code_w_scope total size is to long, clips outer document");
if (i) {
if (o) {
var se = s ? a(ne) : ne;
_[b] = isolateEvalWithHash(functionCache, se, ne, _);
} else _[b] = isolateEval(ne);
_[b].scope = oe;
} else _[b] = new code(ne, oe);
} else {
if (v !== constants.BSON_DATA_DBPOINTER) throw new Error("Detected unknown BSON type " + v.toString(16) + ' for fieldname "' + b + '", are you using the latest BSON parser?');
var ae = e[t++] | e[t++] << 8 | e[t++] << 16 | e[t++] << 24;
if (ae <= 0 || ae > e.length - t || 0 !== e[t + ae - 1]) throw new Error("bad string length in bson");
if (!validateUtf8$1(e, t, t + ae - 1)) throw new Error("Invalid UTF-8 string in BSON document");
var ue = e.toString("utf8", t, t + ae - 1);
t += ae;
var ce = Buffer$4.alloc(12);
e.copy(ce, 0, t, t + 12);
var fe = new objectid(ce);
t += 12, _[b] = new db_ref(ue, fe);
}
}
if (y !== t - d) {
if (r) throw new Error("corrupt array bson");
throw new Error("corrupt object bson");
}
var le = Object.keys(_).filter(function(e) {
return e.startsWith("$");
}), he = !0;
if (le.forEach(function(e) {
-1 === [ "$ref", "$id", "$db" ].indexOf(e) && (he = !1);
}), !he) return _;
if (null != _.$id && null != _.$ref) {
var pe = Object.assign({}, _);
return delete pe.$ref, delete pe.$id, delete pe.$db, new db_ref(_.$ref, _.$id, _.$db || null, pe);
}
return _;
}
function isolateEvalWithHash(functionCache, hash, functionString, object) {
var value = null;
return null == functionCache[hash] && (eval("value = " + functionString), functionCache[hash] = value), 
functionCache[hash].bind(object);
}
function isolateEval(functionString) {
var value = null;
return eval("value = " + functionString), value;
}
var deserializer = deserialize$1;
function readIEEE754(e, t, n, r, i) {
var o, s, a = "big" === n, u = 8 * i - r - 1, c = (1 << u) - 1, f = c >> 1, l = -7, h = a ? 0 : i - 1, p = a ? 1 : -1, d = e[t + h];
for (h += p, o = d & (1 << -l) - 1, d >>= -l, l += u; l > 0; o = 256 * o + e[t + h], 
h += p, l -= 8) ;
for (s = o & (1 << -l) - 1, o >>= -l, l += r; l > 0; s = 256 * s + e[t + h], h += p, 
l -= 8) ;
if (0 === o) o = 1 - f; else {
if (o === c) return s ? NaN : 1 / 0 * (d ? -1 : 1);
s += Math.pow(2, r), o -= f;
}
return (d ? -1 : 1) * s * Math.pow(2, o - r);
}
function writeIEEE754(e, t, n, r, i, o) {
var s, a, u, c = "big" === r, f = 8 * o - i - 1, l = (1 << f) - 1, h = l >> 1, p = 23 === i ? Math.pow(2, -24) - Math.pow(2, -77) : 0, d = c ? o - 1 : 0, y = c ? -1 : 1, _ = t < 0 || 0 === t && 1 / t < 0 ? 1 : 0;
for (t = Math.abs(t), isNaN(t) || t === 1 / 0 ? (a = isNaN(t) ? 1 : 0, s = l) : (s = Math.floor(Math.log(t) / Math.LN2), 
t * (u = Math.pow(2, -s)) < 1 && (s--, u *= 2), (t += s + h >= 1 ? p / u : p * Math.pow(2, 1 - h)) * u >= 2 && (s++, 
u /= 2), s + h >= l ? (a = 0, s = l) : s + h >= 1 ? (a = (t * u - 1) * Math.pow(2, i), 
s += h) : (a = t * Math.pow(2, h - 1) * Math.pow(2, i), s = 0)), isNaN(t) && (a = 0); i >= 8; ) e[n + d] = 255 & a, 
d += y, a /= 256, i -= 8;
for (s = s << i | a, isNaN(t) && (s += 8), f += i; f > 0; ) e[n + d] = 255 & s, 
d += y, s /= 256, f -= 8;
e[n + d - y] |= 128 * _;
}
var float_parser = {
readIEEE754: readIEEE754,
writeIEEE754: writeIEEE754
};
function _typeof$3(e) {
return (_typeof$3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
return typeof e;
} : function(e) {
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
})(e);
}
var Buffer$5 = buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer, writeIEEE754$1 = float_parser.writeIEEE754, normalizedFunctionString$1 = utils.normalizedFunctionString, regexp$1 = /\x00/, ignoreKeys = new Set([ "$db", "$ref", "$id", "$clusterTime" ]), isDate$1 = function(e) {
return "object" === _typeof$3(e) && "[object Date]" === Object.prototype.toString.call(e);
}, isRegExp$1 = function(e) {
return "[object RegExp]" === Object.prototype.toString.call(e);
};
function serializeString(e, t, n, r, i) {
e[r++] = constants.BSON_DATA_STRING;
var o = i ? e.write(t, r, "ascii") : e.write(t, r, "utf8");
e[(r = r + o + 1) - 1] = 0;
var s = e.write(n, r + 4, "utf8");
return e[r + 3] = s + 1 >> 24 & 255, e[r + 2] = s + 1 >> 16 & 255, e[r + 1] = s + 1 >> 8 & 255, 
e[r] = s + 1 & 255, r = r + 4 + s, e[r++] = 0, r;
}
function serializeNumber(e, t, n, r, i) {
if (Math.floor(n) === n && n >= constants.JS_INT_MIN && n <= constants.JS_INT_MAX) if (n >= constants.BSON_INT32_MIN && n <= constants.BSON_INT32_MAX) e[r++] = constants.BSON_DATA_INT, 
r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, e[r++] = 255 & n, 
e[r++] = n >> 8 & 255, e[r++] = n >> 16 & 255, e[r++] = n >> 24 & 255; else if (n >= constants.JS_INT_MIN && n <= constants.JS_INT_MAX) e[r++] = constants.BSON_DATA_NUMBER, 
r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, writeIEEE754$1(e, n, r, "little", 52, 8), 
r += 8; else {
e[r++] = constants.BSON_DATA_LONG, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0;
var o = long_1.fromNumber(n), s = o.getLowBits(), a = o.getHighBits();
e[r++] = 255 & s, e[r++] = s >> 8 & 255, e[r++] = s >> 16 & 255, e[r++] = s >> 24 & 255, 
e[r++] = 255 & a, e[r++] = a >> 8 & 255, e[r++] = a >> 16 & 255, e[r++] = a >> 24 & 255;
} else e[r++] = constants.BSON_DATA_NUMBER, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0, writeIEEE754$1(e, n, r, "little", 52, 8), r += 8;
return r;
}
function serializeNull(e, t, n, r, i) {
return e[r++] = constants.BSON_DATA_NULL, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0, r;
}
function serializeBoolean(e, t, n, r, i) {
return e[r++] = constants.BSON_DATA_BOOLEAN, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0, e[r++] = n ? 1 : 0, r;
}
function serializeDate(e, t, n, r, i) {
e[r++] = constants.BSON_DATA_DATE, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0;
var o = long_1.fromNumber(n.getTime()), s = o.getLowBits(), a = o.getHighBits();
return e[r++] = 255 & s, e[r++] = s >> 8 & 255, e[r++] = s >> 16 & 255, e[r++] = s >> 24 & 255, 
e[r++] = 255 & a, e[r++] = a >> 8 & 255, e[r++] = a >> 16 & 255, e[r++] = a >> 24 & 255, 
r;
}
function serializeRegExp(e, t, n, r, i) {
if (e[r++] = constants.BSON_DATA_REGEXP, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0, n.source && null != n.source.match(regexp$1)) throw Error("value " + n.source + " must not contain null bytes");
return r += e.write(n.source, r, "utf8"), e[r++] = 0, n.ignoreCase && (e[r++] = 105), 
n.global && (e[r++] = 115), n.multiline && (e[r++] = 109), e[r++] = 0, r;
}
function serializeBSONRegExp(e, t, n, r, i) {
if (e[r++] = constants.BSON_DATA_REGEXP, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0, null != n.pattern.match(regexp$1)) throw Error("pattern " + n.pattern + " must not contain null bytes");
return r += e.write(n.pattern, r, "utf8"), e[r++] = 0, r += e.write(n.options.split("").sort().join(""), r, "utf8"), 
e[r++] = 0, r;
}
function serializeMinMax(e, t, n, r, i) {
return null === n ? e[r++] = constants.BSON_DATA_NULL : "MinKey" === n._bsontype ? e[r++] = constants.BSON_DATA_MIN_KEY : e[r++] = constants.BSON_DATA_MAX_KEY, 
r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0, r;
}
function serializeObjectId(e, t, n, r, i) {
if (e[r++] = constants.BSON_DATA_OID, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0, "string" == typeof n.id) e.write(n.id, r, "binary"); else {
if (!n.id || !n.id.copy) throw new TypeError("object [" + JSON.stringify(n) + "] is not a valid ObjectId");
n.id.copy(e, r, 0, 12);
}
return r + 12;
}
function serializeBuffer(e, t, n, r, i) {
e[r++] = constants.BSON_DATA_BINARY, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0;
var o = n.length;
return e[r++] = 255 & o, e[r++] = o >> 8 & 255, e[r++] = o >> 16 & 255, e[r++] = o >> 24 & 255, 
e[r++] = constants.BSON_BINARY_SUBTYPE_DEFAULT, n.copy(e, r, 0, o), r + o;
}
function serializeObject(e, t, n, r, i, o, s, a, u, c) {
for (var f = 0; f < c.length; f++) if (c[f] === n) throw new Error("cyclic dependency detected");
c.push(n), e[r++] = Array.isArray(n) ? constants.BSON_DATA_ARRAY : constants.BSON_DATA_OBJECT, 
r += u ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0;
var l = serializeInto(e, n, i, r, o + 1, s, a, c);
return c.pop(), l;
}
function serializeDecimal128(e, t, n, r, i) {
return e[r++] = constants.BSON_DATA_DECIMAL128, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0, n.bytes.copy(e, r, 0, 16), r + 16;
}
function serializeLong(e, t, n, r, i) {
e[r++] = "Long" === n._bsontype ? constants.BSON_DATA_LONG : constants.BSON_DATA_TIMESTAMP, 
r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), e[r++] = 0;
var o = n.getLowBits(), s = n.getHighBits();
return e[r++] = 255 & o, e[r++] = o >> 8 & 255, e[r++] = o >> 16 & 255, e[r++] = o >> 24 & 255, 
e[r++] = 255 & s, e[r++] = s >> 8 & 255, e[r++] = s >> 16 & 255, e[r++] = s >> 24 & 255, 
r;
}
function serializeInt32(e, t, n, r, i) {
return e[r++] = constants.BSON_DATA_INT, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0, e[r++] = 255 & n, e[r++] = n >> 8 & 255, e[r++] = n >> 16 & 255, e[r++] = n >> 24 & 255, 
r;
}
function serializeDouble(e, t, n, r, i) {
return e[r++] = constants.BSON_DATA_NUMBER, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0, writeIEEE754$1(e, n.value, r, "little", 52, 8), r + 8;
}
function serializeFunction(e, t, n, r, i, o, s) {
e[r++] = constants.BSON_DATA_CODE, r += s ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0;
var a = normalizedFunctionString$1(n), u = e.write(a, r + 4, "utf8") + 1;
return e[r] = 255 & u, e[r + 1] = u >> 8 & 255, e[r + 2] = u >> 16 & 255, e[r + 3] = u >> 24 & 255, 
r = r + 4 + u - 1, e[r++] = 0, r;
}
function serializeCode(e, t, n, r, i, o, s, a, u) {
if (n.scope && "object" === _typeof$3(n.scope)) {
e[r++] = constants.BSON_DATA_CODE_W_SCOPE, r += u ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0;
var c = r, f = "string" == typeof n.code ? n.code : n.code.toString();
r += 4;
var l = e.write(f, r + 4, "utf8") + 1;
e[r] = 255 & l, e[r + 1] = l >> 8 & 255, e[r + 2] = l >> 16 & 255, e[r + 3] = l >> 24 & 255, 
e[r + 4 + l - 1] = 0, r = r + l + 4;
var h = serializeInto(e, n.scope, i, r, o + 1, s, a);
r = h - 1;
var p = h - c;
e[c++] = 255 & p, e[c++] = p >> 8 & 255, e[c++] = p >> 16 & 255, e[c++] = p >> 24 & 255, 
e[r++] = 0;
} else {
e[r++] = constants.BSON_DATA_CODE, r += u ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0;
var d = n.code.toString(), y = e.write(d, r + 4, "utf8") + 1;
e[r] = 255 & y, e[r + 1] = y >> 8 & 255, e[r + 2] = y >> 16 & 255, e[r + 3] = y >> 24 & 255, 
r = r + 4 + y - 1, e[r++] = 0;
}
return r;
}
function serializeBinary(e, t, n, r, i) {
e[r++] = constants.BSON_DATA_BINARY, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0;
var o = n.value(!0), s = n.position;
return n.sub_type === binary.SUBTYPE_BYTE_ARRAY && (s += 4), e[r++] = 255 & s, e[r++] = s >> 8 & 255, 
e[r++] = s >> 16 & 255, e[r++] = s >> 24 & 255, e[r++] = n.sub_type, n.sub_type === binary.SUBTYPE_BYTE_ARRAY && (s -= 4, 
e[r++] = 255 & s, e[r++] = s >> 8 & 255, e[r++] = s >> 16 & 255, e[r++] = s >> 24 & 255), 
o.copy(e, r, 0, n.position), r + n.position;
}
function serializeSymbol(e, t, n, r, i) {
e[r++] = constants.BSON_DATA_SYMBOL, r += i ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0;
var o = e.write(n.value, r + 4, "utf8") + 1;
return e[r] = 255 & o, e[r + 1] = o >> 8 & 255, e[r + 2] = o >> 16 & 255, e[r + 3] = o >> 24 & 255, 
r = r + 4 + o - 1, e[r++] = 0, r;
}
function serializeDBRef(e, t, n, r, i, o, s) {
e[r++] = constants.BSON_DATA_OBJECT, r += s ? e.write(t, r, "ascii") : e.write(t, r, "utf8"), 
e[r++] = 0;
var a, u = r, c = {
$ref: n.collection || n.namespace,
$id: n.oid
};
null != n.db && (c.$db = n.db);
var f = (a = serializeInto(e, c = Object.assign(c, n.fields), !1, r, i + 1, o)) - u;
return e[u++] = 255 & f, e[u++] = f >> 8 & 255, e[u++] = f >> 16 & 255, e[u++] = f >> 24 & 255, 
a;
}
function serializeInto(e, t, n, r, i, o, s, a) {
r = r || 0, (a = a || []).push(t);
var u = r + 4;
if (Array.isArray(t)) for (var c = 0; c < t.length; c++) {
var f = "" + c, l = t[c];
if (l && l.toBSON) {
if ("function" != typeof l.toBSON) throw new TypeError("toBSON is not a function");
l = l.toBSON();
}
var h = _typeof$3(l);
if ("string" === h) u = serializeString(e, f, l, u, !0); else if ("number" === h) u = serializeNumber(e, f, l, u, !0); else if ("boolean" === h) u = serializeBoolean(e, f, l, u, !0); else if (l instanceof Date || isDate$1(l)) u = serializeDate(e, f, l, u, !0); else if (void 0 === l) u = serializeNull(e, f, l, u, !0); else if (null === l) u = serializeNull(e, f, l, u, !0); else if ("ObjectId" === l._bsontype || "ObjectID" === l._bsontype) u = serializeObjectId(e, f, l, u, !0); else if (Buffer$5.isBuffer(l)) u = serializeBuffer(e, f, l, u, !0); else if (l instanceof RegExp || isRegExp$1(l)) u = serializeRegExp(e, f, l, u, !0); else if ("object" === h && null == l._bsontype) u = serializeObject(e, f, l, u, n, i, o, s, !0, a); else if ("object" === h && "Decimal128" === l._bsontype) u = serializeDecimal128(e, f, l, u, !0); else if ("Long" === l._bsontype || "Timestamp" === l._bsontype) u = serializeLong(e, f, l, u, !0); else if ("Double" === l._bsontype) u = serializeDouble(e, f, l, u, !0); else if ("function" == typeof l && o) u = serializeFunction(e, f, l, u, n, i, o, !0); else if ("Code" === l._bsontype) u = serializeCode(e, f, l, u, n, i, o, s, !0); else if ("Binary" === l._bsontype) u = serializeBinary(e, f, l, u, !0); else if ("Symbol" === l._bsontype) u = serializeSymbol(e, f, l, u, !0); else if ("DBRef" === l._bsontype) u = serializeDBRef(e, f, l, u, i, o, !0); else if ("BSONRegExp" === l._bsontype) u = serializeBSONRegExp(e, f, l, u, !0); else if ("Int32" === l._bsontype) u = serializeInt32(e, f, l, u, !0); else if ("MinKey" === l._bsontype || "MaxKey" === l._bsontype) u = serializeMinMax(e, f, l, u, !0); else if (void 0 !== l._bsontype) throw new TypeError("Unrecognized or invalid _bsontype: " + l._bsontype);
} else if (t instanceof map) for (var p = t.entries(), d = !1; !d; ) {
var y = p.next();
if (!(d = y.done)) {
var _ = y.value[0], g = y.value[1], v = _typeof$3(g);
if ("string" == typeof _ && !ignoreKeys.has(_)) {
if (null != _.match(regexp$1)) throw Error("key " + _ + " must not contain null bytes");
if (n) {
if ("$" === _[0]) throw Error("key " + _ + " must not start with '$'");
if (~_.indexOf(".")) throw Error("key " + _ + " must not contain '.'");
}
}
if ("string" === v) u = serializeString(e, _, g, u); else if ("number" === v) u = serializeNumber(e, _, g, u); else if ("boolean" === v) u = serializeBoolean(e, _, g, u); else if (g instanceof Date || isDate$1(g)) u = serializeDate(e, _, g, u); else if (null === g || void 0 === g && !1 === s) u = serializeNull(e, _, g, u); else if ("ObjectId" === g._bsontype || "ObjectID" === g._bsontype) u = serializeObjectId(e, _, g, u); else if (Buffer$5.isBuffer(g)) u = serializeBuffer(e, _, g, u); else if (g instanceof RegExp || isRegExp$1(g)) u = serializeRegExp(e, _, g, u); else if ("object" === v && null == g._bsontype) u = serializeObject(e, _, g, u, n, i, o, s, !1, a); else if ("object" === v && "Decimal128" === g._bsontype) u = serializeDecimal128(e, _, g, u); else if ("Long" === g._bsontype || "Timestamp" === g._bsontype) u = serializeLong(e, _, g, u); else if ("Double" === g._bsontype) u = serializeDouble(e, _, g, u); else if ("Code" === g._bsontype) u = serializeCode(e, _, g, u, n, i, o, s); else if ("function" == typeof g && o) u = serializeFunction(e, _, g, u, n, i, o); else if ("Binary" === g._bsontype) u = serializeBinary(e, _, g, u); else if ("Symbol" === g._bsontype) u = serializeSymbol(e, _, g, u); else if ("DBRef" === g._bsontype) u = serializeDBRef(e, _, g, u, i, o); else if ("BSONRegExp" === g._bsontype) u = serializeBSONRegExp(e, _, g, u); else if ("Int32" === g._bsontype) u = serializeInt32(e, _, g, u); else if ("MinKey" === g._bsontype || "MaxKey" === g._bsontype) u = serializeMinMax(e, _, g, u); else if (void 0 !== g._bsontype) throw new TypeError("Unrecognized or invalid _bsontype: " + g._bsontype);
}
} else {
if (t.toBSON) {
if ("function" != typeof t.toBSON) throw new TypeError("toBSON is not a function");
if (null != (t = t.toBSON()) && "object" !== _typeof$3(t)) throw new TypeError("toBSON function did not return an object");
}
for (var m in t) {
var b = t[m];
if (b && b.toBSON) {
if ("function" != typeof b.toBSON) throw new TypeError("toBSON is not a function");
b = b.toBSON();
}
var w = _typeof$3(b);
if ("string" == typeof m && !ignoreKeys.has(m)) {
if (null != m.match(regexp$1)) throw Error("key " + m + " must not contain null bytes");
if (n) {
if ("$" === m[0]) throw Error("key " + m + " must not start with '$'");
if (~m.indexOf(".")) throw Error("key " + m + " must not contain '.'");
}
}
if ("string" === w) u = serializeString(e, m, b, u); else if ("number" === w) u = serializeNumber(e, m, b, u); else if ("boolean" === w) u = serializeBoolean(e, m, b, u); else if (b instanceof Date || isDate$1(b)) u = serializeDate(e, m, b, u); else if (void 0 === b) !1 === s && (u = serializeNull(e, m, b, u)); else if (null === b) u = serializeNull(e, m, b, u); else if ("ObjectId" === b._bsontype || "ObjectID" === b._bsontype) u = serializeObjectId(e, m, b, u); else if (Buffer$5.isBuffer(b)) u = serializeBuffer(e, m, b, u); else if (b instanceof RegExp || isRegExp$1(b)) u = serializeRegExp(e, m, b, u); else if ("object" === w && null == b._bsontype) u = serializeObject(e, m, b, u, n, i, o, s, !1, a); else if ("object" === w && "Decimal128" === b._bsontype) u = serializeDecimal128(e, m, b, u); else if ("Long" === b._bsontype || "Timestamp" === b._bsontype) u = serializeLong(e, m, b, u); else if ("Double" === b._bsontype) u = serializeDouble(e, m, b, u); else if ("Code" === b._bsontype) u = serializeCode(e, m, b, u, n, i, o, s); else if ("function" == typeof b && o) u = serializeFunction(e, m, b, u, n, i, o); else if ("Binary" === b._bsontype) u = serializeBinary(e, m, b, u); else if ("Symbol" === b._bsontype) u = serializeSymbol(e, m, b, u); else if ("DBRef" === b._bsontype) u = serializeDBRef(e, m, b, u, i, o); else if ("BSONRegExp" === b._bsontype) u = serializeBSONRegExp(e, m, b, u); else if ("Int32" === b._bsontype) u = serializeInt32(e, m, b, u); else if ("MinKey" === b._bsontype || "MaxKey" === b._bsontype) u = serializeMinMax(e, m, b, u); else if (void 0 !== b._bsontype) throw new TypeError("Unrecognized or invalid _bsontype: " + b._bsontype);
}
}
a.pop(), e[u++] = 0;
var E = u - r;
return e[r++] = 255 & E, e[r++] = E >> 8 & 255, e[r++] = E >> 16 & 255, e[r++] = E >> 24 & 255, 
u;
}
var serializer = serializeInto;
function _typeof$4(e) {
return (_typeof$4 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
return typeof e;
} : function(e) {
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
})(e);
}
var Buffer$6 = buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer, normalizedFunctionString$2 = utils.normalizedFunctionString;
function isDate$2(e) {
return "object" === _typeof$4(e) && "[object Date]" === Object.prototype.toString.call(e);
}
function calculateObjectSize(e, t, n) {
var r = 5;
if (Array.isArray(e)) for (var i = 0; i < e.length; i++) r += calculateElement(i.toString(), e[i], t, !0, n); else for (var o in e.toBSON && (e = e.toBSON()), 
e) r += calculateElement(o, e[o], t, !1, n);
return r;
}
function calculateElement(e, t, n, r, i) {
switch (t && t.toBSON && (t = t.toBSON()), _typeof$4(t)) {
case "string":
return 1 + Buffer$6.byteLength(e, "utf8") + 1 + 4 + Buffer$6.byteLength(t, "utf8") + 1;

case "number":
return Math.floor(t) === t && t >= constants.JS_INT_MIN && t <= constants.JS_INT_MAX && t >= constants.BSON_INT32_MIN && t <= constants.BSON_INT32_MAX ? (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 5 : (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 9;

case "undefined":
return r || !i ? (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 1 : 0;

case "boolean":
return (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 2;

case "object":
if (null == t || "MinKey" === t._bsontype || "MaxKey" === t._bsontype) return (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 1;
if ("ObjectId" === t._bsontype || "ObjectID" === t._bsontype) return (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 13;
if (t instanceof Date || isDate$2(t)) return (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 9;
if (void 0 !== Buffer$6 && Buffer$6.isBuffer(t)) return (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 6 + t.length;
if ("Long" === t._bsontype || "Double" === t._bsontype || "Timestamp" === t._bsontype) return (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 9;
if ("Decimal128" === t._bsontype) return (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 17;
if ("Code" === t._bsontype) return null != t.scope && Object.keys(t.scope).length > 0 ? (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 1 + 4 + 4 + Buffer$6.byteLength(t.code.toString(), "utf8") + 1 + calculateObjectSize(t.scope, n, i) : (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 1 + 4 + Buffer$6.byteLength(t.code.toString(), "utf8") + 1;
if ("Binary" === t._bsontype) return t.sub_type === binary.SUBTYPE_BYTE_ARRAY ? (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + (t.position + 1 + 4 + 1 + 4) : (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + (t.position + 1 + 4 + 1);
if ("Symbol" === t._bsontype) return (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + Buffer$6.byteLength(t.value, "utf8") + 4 + 1 + 1;
if ("DBRef" === t._bsontype) {
var o = Object.assign({
$ref: t.collection,
$id: t.oid
}, t.fields);
return null != t.db && (o.$db = t.db), (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 1 + calculateObjectSize(o, n, i);
}
return t instanceof RegExp || "[object RegExp]" === Object.prototype.toString.call(t) ? (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 1 + Buffer$6.byteLength(t.source, "utf8") + 1 + (t.global ? 1 : 0) + (t.ignoreCase ? 1 : 0) + (t.multiline ? 1 : 0) + 1 : "BSONRegExp" === t._bsontype ? (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 1 + Buffer$6.byteLength(t.pattern, "utf8") + 1 + Buffer$6.byteLength(t.options, "utf8") + 1 : (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + calculateObjectSize(t, n, i) + 1;

case "function":
if (t instanceof RegExp || "[object RegExp]" === Object.prototype.toString.call(t) || "[object RegExp]" === String.call(t)) return (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 1 + Buffer$6.byteLength(t.source, "utf8") + 1 + (t.global ? 1 : 0) + (t.ignoreCase ? 1 : 0) + (t.multiline ? 1 : 0) + 1;
if (n && null != t.scope && Object.keys(t.scope).length > 0) return (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 1 + 4 + 4 + Buffer$6.byteLength(normalizedFunctionString$2(t), "utf8") + 1 + calculateObjectSize(t.scope, n, i);
if (n) return (null != e ? Buffer$6.byteLength(e, "utf8") + 1 : 0) + 1 + 4 + Buffer$6.byteLength(normalizedFunctionString$2(t), "utf8") + 1;
}
return 0;
}
var calculate_size = calculateObjectSize, Buffer$7 = buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer, ensure_buffer = function(e) {
if (e instanceof Buffer$7) return e;
if (e instanceof Uint8Array) return Buffer$7.from(e.buffer);
throw new TypeError("Must use either Buffer or Uint8Array");
}, Buffer$8 = buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer, MAXSIZE = 17825792, buffer$1 = Buffer$8.alloc(MAXSIZE);
function setInternalBufferSize(e) {
buffer$1.length < e && (buffer$1 = Buffer$8.alloc(e));
}
function serialize$1(e, t) {
var n = "boolean" == typeof (t = t || {}).checkKeys && t.checkKeys, r = "boolean" == typeof t.serializeFunctions && t.serializeFunctions, i = "boolean" != typeof t.ignoreUndefined || t.ignoreUndefined, o = "number" == typeof t.minInternalBufferSize ? t.minInternalBufferSize : MAXSIZE;
buffer$1.length < o && (buffer$1 = Buffer$8.alloc(o));
var s = serializer(buffer$1, e, n, 0, 0, r, i, []), a = Buffer$8.alloc(s);
return buffer$1.copy(a, 0, 0, a.length), a;
}
function serializeWithBufferAndIndex(e, t, n) {
var r = "boolean" == typeof (n = n || {}).checkKeys && n.checkKeys, i = "boolean" == typeof n.serializeFunctions && n.serializeFunctions, o = "boolean" != typeof n.ignoreUndefined || n.ignoreUndefined, s = "number" == typeof n.index ? n.index : 0, a = serializer(buffer$1, e, r, 0, 0, i, o);
return buffer$1.copy(t, s, 0, a), s + a - 1;
}
function deserialize$2(e, t) {
return e = ensure_buffer(e), deserializer(e, t);
}
function calculateObjectSize$1(e, t) {
var n = "boolean" == typeof (t = t || {}).serializeFunctions && t.serializeFunctions, r = "boolean" != typeof t.ignoreUndefined || t.ignoreUndefined;
return calculate_size(e, n, r);
}
function deserializeStream(e, t, n, r, i, o) {
o = Object.assign({
allowObjectSmallerThanBufferSize: !0
}, o), e = ensure_buffer(e);
for (var s = t, a = 0; a < n; a++) {
var u = e[s] | e[s + 1] << 8 | e[s + 2] << 16 | e[s + 3] << 24;
o.index = s, r[i + a] = deserializer(e, o), s += u;
}
return s;
}
var bson = {
BSON_INT32_MAX: constants.BSON_INT32_MAX,
BSON_INT32_MIN: constants.BSON_INT32_MIN,
BSON_INT64_MAX: constants.BSON_INT64_MAX,
BSON_INT64_MIN: constants.BSON_INT64_MIN,
JS_INT_MAX: constants.JS_INT_MAX,
JS_INT_MIN: constants.JS_INT_MIN,
BSON_DATA_NUMBER: constants.BSON_DATA_NUMBER,
BSON_DATA_STRING: constants.BSON_DATA_STRING,
BSON_DATA_OBJECT: constants.BSON_DATA_OBJECT,
BSON_DATA_ARRAY: constants.BSON_DATA_ARRAY,
BSON_DATA_BINARY: constants.BSON_DATA_BINARY,
BSON_DATA_UNDEFINED: constants.BSON_DATA_UNDEFINED,
BSON_DATA_OID: constants.BSON_DATA_OID,
BSON_DATA_BOOLEAN: constants.BSON_DATA_BOOLEAN,
BSON_DATA_DATE: constants.BSON_DATA_DATE,
BSON_DATA_NULL: constants.BSON_DATA_NULL,
BSON_DATA_REGEXP: constants.BSON_DATA_REGEXP,
BSON_DATA_DBPOINTER: constants.BSON_DATA_DBPOINTER,
BSON_DATA_CODE: constants.BSON_DATA_CODE,
BSON_DATA_SYMBOL: constants.BSON_DATA_SYMBOL,
BSON_DATA_CODE_W_SCOPE: constants.BSON_DATA_CODE_W_SCOPE,
BSON_DATA_INT: constants.BSON_DATA_INT,
BSON_DATA_TIMESTAMP: constants.BSON_DATA_TIMESTAMP,
BSON_DATA_LONG: constants.BSON_DATA_LONG,
BSON_DATA_DECIMAL128: constants.BSON_DATA_DECIMAL128,
BSON_DATA_MIN_KEY: constants.BSON_DATA_MIN_KEY,
BSON_DATA_MAX_KEY: constants.BSON_DATA_MAX_KEY,
BSON_BINARY_SUBTYPE_DEFAULT: constants.BSON_BINARY_SUBTYPE_DEFAULT,
BSON_BINARY_SUBTYPE_FUNCTION: constants.BSON_BINARY_SUBTYPE_FUNCTION,
BSON_BINARY_SUBTYPE_BYTE_ARRAY: constants.BSON_BINARY_SUBTYPE_BYTE_ARRAY,
BSON_BINARY_SUBTYPE_UUID: constants.BSON_BINARY_SUBTYPE_UUID,
BSON_BINARY_SUBTYPE_MD5: constants.BSON_BINARY_SUBTYPE_MD5,
BSON_BINARY_SUBTYPE_USER_DEFINED: constants.BSON_BINARY_SUBTYPE_USER_DEFINED,
Code: code,
Map: map,
BSONSymbol: symbol,
DBRef: db_ref,
Binary: binary,
ObjectId: objectid,
Long: long_1,
Timestamp: timestamp,
Double: double_1,
Int32: int_32,
MinKey: min_key,
MaxKey: max_key,
BSONRegExp: regexp,
Decimal128: decimal128,
serialize: serialize$1,
serializeWithBufferAndIndex: serializeWithBufferAndIndex,
deserialize: deserialize$2,
calculateObjectSize: calculateObjectSize$1,
deserializeStream: deserializeStream,
setInternalBufferSize: setInternalBufferSize,
ObjectID: objectid,
EJSON: extended_json
}, bson_1 = bson.BSON_INT32_MAX, bson_2 = bson.BSON_INT32_MIN, bson_3 = bson.BSON_INT64_MAX, bson_4 = bson.BSON_INT64_MIN, bson_5 = bson.JS_INT_MAX, bson_6 = bson.JS_INT_MIN, bson_7 = bson.BSON_DATA_NUMBER, bson_8 = bson.BSON_DATA_STRING, bson_9 = bson.BSON_DATA_OBJECT, bson_10 = bson.BSON_DATA_ARRAY, bson_11 = bson.BSON_DATA_BINARY, bson_12 = bson.BSON_DATA_UNDEFINED, bson_13 = bson.BSON_DATA_OID, bson_14 = bson.BSON_DATA_BOOLEAN, bson_15 = bson.BSON_DATA_DATE, bson_16 = bson.BSON_DATA_NULL, bson_17 = bson.BSON_DATA_REGEXP, bson_18 = bson.BSON_DATA_DBPOINTER, bson_19 = bson.BSON_DATA_CODE, bson_20 = bson.BSON_DATA_SYMBOL, bson_21 = bson.BSON_DATA_CODE_W_SCOPE, bson_22 = bson.BSON_DATA_INT, bson_23 = bson.BSON_DATA_TIMESTAMP, bson_24 = bson.BSON_DATA_LONG, bson_25 = bson.BSON_DATA_DECIMAL128, bson_26 = bson.BSON_DATA_MIN_KEY, bson_27 = bson.BSON_DATA_MAX_KEY, bson_28 = bson.BSON_BINARY_SUBTYPE_DEFAULT, bson_29 = bson.BSON_BINARY_SUBTYPE_FUNCTION, bson_30 = bson.BSON_BINARY_SUBTYPE_BYTE_ARRAY, bson_31 = bson.BSON_BINARY_SUBTYPE_UUID, bson_32 = bson.BSON_BINARY_SUBTYPE_MD5, bson_33 = bson.BSON_BINARY_SUBTYPE_USER_DEFINED, bson_34 = bson.Code, bson_35 = bson.BSONSymbol, bson_36 = bson.DBRef, bson_37 = bson.Binary, bson_38 = bson.ObjectId, bson_39 = bson.Long, bson_40 = bson.Timestamp, bson_41 = bson.Double, bson_42 = bson.Int32, bson_43 = bson.MinKey, bson_44 = bson.MaxKey, bson_45 = bson.BSONRegExp, bson_46 = bson.Decimal128, bson_47 = bson.serialize, bson_48 = bson.serializeWithBufferAndIndex, bson_49 = bson.deserialize, bson_50 = bson.calculateObjectSize, bson_51 = bson.deserializeStream, bson_52 = bson.setInternalBufferSize, bson_53 = bson.ObjectID, bson_54 = bson.EJSON, _unused_webpack_default_export = bson;
}).call(this, __webpack_require__(8), __webpack_require__(3).Buffer);
}, function(e, t, n) {
"use strict";
(function() {
n.d(t, "h", function() {
return a;
}), n.d(t, "e", function() {
return u;
}), n.d(t, "g", function() {
return c;
}), n.d(t, "d", function() {
return f;
}), n.d(t, "a", function() {
return h;
}), n.d(t, "f", function() {
return y;
}), n.d(t, "c", function() {
return _;
}), n.d(t, "b", function() {
return l;
});
var e = n(0), r = e.constants.setSdkName, i = e.constants.setProtocol, o = "", s = "@cloudbase/js-sdk";
function a(e) {
o = e;
}
function u() {
return o;
}
function c(e) {
s = e, r(e);
}
function f() {
return s;
}
var l, h = "2020-01-10", p = "undefined" != typeof location && "http:" === location.protocol ? "http:" : "https:", d = "//tcb-api.tencentcloudapi.com/web";
function y(e, t) {
d = e, t && (p = t, i(t));
}
function _() {
return {
BASE_URL: d,
PROTOCOL: p
};
}
!function(e) {
e.ANONYMOUS = "ANONYMOUS", e.WECHAT = "WECHAT", e.CUSTOM = "CUSTOM", e.NULL = "NULL";
}(l || (l = {}));
}).call(this, n(11));
}, function(e, t, n) {
"use strict";
(function(e) {
var r = n(33), i = n(34), o = n(35);
function s() {
return u.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
}
function a(e, t) {
if (s() < t) throw new RangeError("Invalid typed array length");
return u.TYPED_ARRAY_SUPPORT ? (e = new Uint8Array(t)).__proto__ = u.prototype : (null === e && (e = new u(t)), 
e.length = t), e;
}
function u(e, t, n) {
if (!(u.TYPED_ARRAY_SUPPORT || this instanceof u)) return new u(e, t, n);
if ("number" == typeof e) {
if ("string" == typeof t) throw new Error("If encoding is specified then the first argument must be a string");
return l(this, e);
}
return c(this, e, t, n);
}
function c(e, t, n, r) {
if ("number" == typeof t) throw new TypeError('"value" argument must not be a number');
return "undefined" != typeof ArrayBuffer && t instanceof ArrayBuffer ? function(e, t, n, r) {
if (t.byteLength, n < 0 || t.byteLength < n) throw new RangeError("'offset' is out of bounds");
if (t.byteLength < n + (r || 0)) throw new RangeError("'length' is out of bounds");
t = void 0 === n && void 0 === r ? new Uint8Array(t) : void 0 === r ? new Uint8Array(t, n) : new Uint8Array(t, n, r);
u.TYPED_ARRAY_SUPPORT ? (e = t).__proto__ = u.prototype : e = h(e, t);
return e;
}(e, t, n, r) : "string" == typeof t ? function(e, t, n) {
"string" == typeof n && "" !== n || (n = "utf8");
if (!u.isEncoding(n)) throw new TypeError('"encoding" must be a valid string encoding');
var r = 0 | d(t, n), i = (e = a(e, r)).write(t, n);
i !== r && (e = e.slice(0, i));
return e;
}(e, t, n) : function(e, t) {
if (u.isBuffer(t)) {
var n = 0 | p(t.length);
return 0 === (e = a(e, n)).length || t.copy(e, 0, 0, n), e;
}
if (t) {
if ("undefined" != typeof ArrayBuffer && t.buffer instanceof ArrayBuffer || "length" in t) return "number" != typeof t.length || (r = t.length) != r ? a(e, 0) : h(e, t);
if ("Buffer" === t.type && o(t.data)) return h(e, t.data);
}
var r;
throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");
}(e, t);
}
function f(e) {
if ("number" != typeof e) throw new TypeError('"size" argument must be a number');
if (e < 0) throw new RangeError('"size" argument must not be negative');
}
function l(e, t) {
if (f(t), e = a(e, t < 0 ? 0 : 0 | p(t)), !u.TYPED_ARRAY_SUPPORT) for (var n = 0; n < t; ++n) e[n] = 0;
return e;
}
function h(e, t) {
var n = t.length < 0 ? 0 : 0 | p(t.length);
e = a(e, n);
for (var r = 0; r < n; r += 1) e[r] = 255 & t[r];
return e;
}
function p(e) {
if (e >= s()) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + s().toString(16) + " bytes");
return 0 | e;
}
function d(e, t) {
if (u.isBuffer(e)) return e.length;
if ("undefined" != typeof ArrayBuffer && "function" == typeof ArrayBuffer.isView && (ArrayBuffer.isView(e) || e instanceof ArrayBuffer)) return e.byteLength;
"string" != typeof e && (e = "" + e);
var n = e.length;
if (0 === n) return 0;
for (var r = !1; ;) switch (t) {
case "ascii":
case "latin1":
case "binary":
return n;

case "utf8":
case "utf-8":
case void 0:
return $(e).length;

case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return 2 * n;

case "hex":
return n >>> 1;

case "base64":
return q(e).length;

default:
if (r) return $(e).length;
t = ("" + t).toLowerCase(), r = !0;
}
}
function y(e, t, n) {
var r = !1;
if ((void 0 === t || t < 0) && (t = 0), t > this.length) return "";
if ((void 0 === n || n > this.length) && (n = this.length), n <= 0) return "";
if ((n >>>= 0) <= (t >>>= 0)) return "";
for (e || (e = "utf8"); ;) switch (e) {
case "hex":
return R(this, t, n);

case "utf8":
case "utf-8":
return I(this, t, n);

case "ascii":
return T(this, t, n);

case "latin1":
case "binary":
return N(this, t, n);

case "base64":
return O(this, t, n);

case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return P(this, t, n);

default:
if (r) throw new TypeError("Unknown encoding: " + e);
e = (e + "").toLowerCase(), r = !0;
}
}
function _(e, t, n) {
var r = e[t];
e[t] = e[n], e[n] = r;
}
function g(e, t, n, r, i) {
if (0 === e.length) return -1;
if ("string" == typeof n ? (r = n, n = 0) : n > 2147483647 ? n = 2147483647 : n < -2147483648 && (n = -2147483648), 
n = +n, isNaN(n) && (n = i ? 0 : e.length - 1), n < 0 && (n = e.length + n), n >= e.length) {
if (i) return -1;
n = e.length - 1;
} else if (n < 0) {
if (!i) return -1;
n = 0;
}
if ("string" == typeof t && (t = u.from(t, r)), u.isBuffer(t)) return 0 === t.length ? -1 : v(e, t, n, r, i);
if ("number" == typeof t) return t &= 255, u.TYPED_ARRAY_SUPPORT && "function" == typeof Uint8Array.prototype.indexOf ? i ? Uint8Array.prototype.indexOf.call(e, t, n) : Uint8Array.prototype.lastIndexOf.call(e, t, n) : v(e, [ t ], n, r, i);
throw new TypeError("val must be string, number or Buffer");
}
function v(e, t, n, r, i) {
var o, s = 1, a = e.length, u = t.length;
if (void 0 !== r && ("ucs2" === (r = String(r).toLowerCase()) || "ucs-2" === r || "utf16le" === r || "utf-16le" === r)) {
if (e.length < 2 || t.length < 2) return -1;
s = 2, a /= 2, u /= 2, n /= 2;
}
function c(e, t) {
return 1 === s ? e[t] : e.readUInt16BE(t * s);
}
if (i) {
var f = -1;
for (o = n; o < a; o++) if (c(e, o) === c(t, -1 === f ? 0 : o - f)) {
if (-1 === f && (f = o), o - f + 1 === u) return f * s;
} else -1 !== f && (o -= o - f), f = -1;
} else for (n + u > a && (n = a - u), o = n; o >= 0; o--) {
for (var l = !0, h = 0; h < u; h++) if (c(e, o + h) !== c(t, h)) {
l = !1;
break;
}
if (l) return o;
}
return -1;
}
function m(e, t, n, r) {
n = Number(n) || 0;
var i = e.length - n;
r ? (r = Number(r)) > i && (r = i) : r = i;
var o = t.length;
if (o % 2 != 0) throw new TypeError("Invalid hex string");
r > o / 2 && (r = o / 2);
for (var s = 0; s < r; ++s) {
var a = parseInt(t.substr(2 * s, 2), 16);
if (isNaN(a)) return s;
e[n + s] = a;
}
return s;
}
function b(e, t, n, r) {
return F($(t, e.length - n), e, n, r);
}
function w(e, t, n, r) {
return F(function(e) {
for (var t = [], n = 0; n < e.length; ++n) t.push(255 & e.charCodeAt(n));
return t;
}(t), e, n, r);
}
function E(e, t, n, r) {
return w(e, t, n, r);
}
function S(e, t, n, r) {
return F(q(t), e, n, r);
}
function A(e, t, n, r) {
return F(function(e, t) {
for (var n, r, i, o = [], s = 0; s < e.length && !((t -= 2) < 0); ++s) r = (n = e.charCodeAt(s)) >> 8, 
i = n % 256, o.push(i), o.push(r);
return o;
}(t, e.length - n), e, n, r);
}
function O(e, t, n) {
return 0 === t && n === e.length ? r.fromByteArray(e) : r.fromByteArray(e.slice(t, n));
}
function I(e, t, n) {
n = Math.min(e.length, n);
for (var r = [], i = t; i < n; ) {
var o, s, a, u, c = e[i], f = null, l = c > 239 ? 4 : c > 223 ? 3 : c > 191 ? 2 : 1;
if (i + l <= n) switch (l) {
case 1:
c < 128 && (f = c);
break;

case 2:
128 == (192 & (o = e[i + 1])) && (u = (31 & c) << 6 | 63 & o) > 127 && (f = u);
break;

case 3:
o = e[i + 1], s = e[i + 2], 128 == (192 & o) && 128 == (192 & s) && (u = (15 & c) << 12 | (63 & o) << 6 | 63 & s) > 2047 && (u < 55296 || u > 57343) && (f = u);
break;

case 4:
o = e[i + 1], s = e[i + 2], a = e[i + 3], 128 == (192 & o) && 128 == (192 & s) && 128 == (192 & a) && (u = (15 & c) << 18 | (63 & o) << 12 | (63 & s) << 6 | 63 & a) > 65535 && u < 1114112 && (f = u);
}
null === f ? (f = 65533, l = 1) : f > 65535 && (f -= 65536, r.push(f >>> 10 & 1023 | 55296), 
f = 56320 | 1023 & f), r.push(f), i += l;
}
return function(e) {
var t = e.length;
if (t <= 4096) return String.fromCharCode.apply(String, e);
for (var n = "", r = 0; r < t; ) n += String.fromCharCode.apply(String, e.slice(r, r += 4096));
return n;
}(r);
}
t.Buffer = u, t.SlowBuffer = function(e) {
+e != e && (e = 0);
return u.alloc(+e);
}, t.INSPECT_MAX_BYTES = 50, u.TYPED_ARRAY_SUPPORT = void 0 !== e.TYPED_ARRAY_SUPPORT ? e.TYPED_ARRAY_SUPPORT : function() {
try {
var e = new Uint8Array(1);
return e.__proto__ = {
__proto__: Uint8Array.prototype,
foo: function() {
return 42;
}
}, 42 === e.foo() && "function" == typeof e.subarray && 0 === e.subarray(1, 1).byteLength;
} catch (e) {
return !1;
}
}(), t.kMaxLength = s(), u.poolSize = 8192, u._augment = function(e) {
return e.__proto__ = u.prototype, e;
}, u.from = function(e, t, n) {
return c(null, e, t, n);
}, u.TYPED_ARRAY_SUPPORT && (u.prototype.__proto__ = Uint8Array.prototype, u.__proto__ = Uint8Array, 
"undefined" != typeof Symbol && Symbol.species && u[Symbol.species] === u && Object.defineProperty(u, Symbol.species, {
value: null,
configurable: !0
})), u.alloc = function(e, t, n) {
return function(e, t, n, r) {
return f(t), t <= 0 ? a(e, t) : void 0 !== n ? "string" == typeof r ? a(e, t).fill(n, r) : a(e, t).fill(n) : a(e, t);
}(null, e, t, n);
}, u.allocUnsafe = function(e) {
return l(null, e);
}, u.allocUnsafeSlow = function(e) {
return l(null, e);
}, u.isBuffer = function(e) {
return !(null == e || !e._isBuffer);
}, u.compare = function(e, t) {
if (!u.isBuffer(e) || !u.isBuffer(t)) throw new TypeError("Arguments must be Buffers");
if (e === t) return 0;
for (var n = e.length, r = t.length, i = 0, o = Math.min(n, r); i < o; ++i) if (e[i] !== t[i]) {
n = e[i], r = t[i];
break;
}
return n < r ? -1 : r < n ? 1 : 0;
}, u.isEncoding = function(e) {
switch (String(e).toLowerCase()) {
case "hex":
case "utf8":
case "utf-8":
case "ascii":
case "latin1":
case "binary":
case "base64":
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return !0;

default:
return !1;
}
}, u.concat = function(e, t) {
if (!o(e)) throw new TypeError('"list" argument must be an Array of Buffers');
if (0 === e.length) return u.alloc(0);
var n;
if (void 0 === t) for (t = 0, n = 0; n < e.length; ++n) t += e[n].length;
var r = u.allocUnsafe(t), i = 0;
for (n = 0; n < e.length; ++n) {
var s = e[n];
if (!u.isBuffer(s)) throw new TypeError('"list" argument must be an Array of Buffers');
s.copy(r, i), i += s.length;
}
return r;
}, u.byteLength = d, u.prototype._isBuffer = !0, u.prototype.swap16 = function() {
var e = this.length;
if (e % 2 != 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
for (var t = 0; t < e; t += 2) _(this, t, t + 1);
return this;
}, u.prototype.swap32 = function() {
var e = this.length;
if (e % 4 != 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
for (var t = 0; t < e; t += 4) _(this, t, t + 3), _(this, t + 1, t + 2);
return this;
}, u.prototype.swap64 = function() {
var e = this.length;
if (e % 8 != 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
for (var t = 0; t < e; t += 8) _(this, t, t + 7), _(this, t + 1, t + 6), _(this, t + 2, t + 5), 
_(this, t + 3, t + 4);
return this;
}, u.prototype.toString = function() {
var e = 0 | this.length;
return 0 === e ? "" : 0 === arguments.length ? I(this, 0, e) : y.apply(this, arguments);
}, u.prototype.equals = function(e) {
if (!u.isBuffer(e)) throw new TypeError("Argument must be a Buffer");
return this === e || 0 === u.compare(this, e);
}, u.prototype.inspect = function() {
var e = "", n = t.INSPECT_MAX_BYTES;
return this.length > 0 && (e = this.toString("hex", 0, n).match(/.{2}/g).join(" "), 
this.length > n && (e += " ... ")), "<Buffer " + e + ">";
}, u.prototype.compare = function(e, t, n, r, i) {
if (!u.isBuffer(e)) throw new TypeError("Argument must be a Buffer");
if (void 0 === t && (t = 0), void 0 === n && (n = e ? e.length : 0), void 0 === r && (r = 0), 
void 0 === i && (i = this.length), t < 0 || n > e.length || r < 0 || i > this.length) throw new RangeError("out of range index");
if (r >= i && t >= n) return 0;
if (r >= i) return -1;
if (t >= n) return 1;
if (this === e) return 0;
for (var o = (i >>>= 0) - (r >>>= 0), s = (n >>>= 0) - (t >>>= 0), a = Math.min(o, s), c = this.slice(r, i), f = e.slice(t, n), l = 0; l < a; ++l) if (c[l] !== f[l]) {
o = c[l], s = f[l];
break;
}
return o < s ? -1 : s < o ? 1 : 0;
}, u.prototype.includes = function(e, t, n) {
return -1 !== this.indexOf(e, t, n);
}, u.prototype.indexOf = function(e, t, n) {
return g(this, e, t, n, !0);
}, u.prototype.lastIndexOf = function(e, t, n) {
return g(this, e, t, n, !1);
}, u.prototype.write = function(e, t, n, r) {
if (void 0 === t) r = "utf8", n = this.length, t = 0; else if (void 0 === n && "string" == typeof t) r = t, 
n = this.length, t = 0; else {
if (!isFinite(t)) throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
t |= 0, isFinite(n) ? (n |= 0, void 0 === r && (r = "utf8")) : (r = n, n = void 0);
}
var i = this.length - t;
if ((void 0 === n || n > i) && (n = i), e.length > 0 && (n < 0 || t < 0) || t > this.length) throw new RangeError("Attempt to write outside buffer bounds");
r || (r = "utf8");
for (var o = !1; ;) switch (r) {
case "hex":
return m(this, e, t, n);

case "utf8":
case "utf-8":
return b(this, e, t, n);

case "ascii":
return w(this, e, t, n);

case "latin1":
case "binary":
return E(this, e, t, n);

case "base64":
return S(this, e, t, n);

case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return A(this, e, t, n);

default:
if (o) throw new TypeError("Unknown encoding: " + r);
r = ("" + r).toLowerCase(), o = !0;
}
}, u.prototype.toJSON = function() {
return {
type: "Buffer",
data: Array.prototype.slice.call(this._arr || this, 0)
};
};
function T(e, t, n) {
var r = "";
n = Math.min(e.length, n);
for (var i = t; i < n; ++i) r += String.fromCharCode(127 & e[i]);
return r;
}
function N(e, t, n) {
var r = "";
n = Math.min(e.length, n);
for (var i = t; i < n; ++i) r += String.fromCharCode(e[i]);
return r;
}
function R(e, t, n) {
var r = e.length;
(!t || t < 0) && (t = 0), (!n || n < 0 || n > r) && (n = r);
for (var i = "", o = t; o < n; ++o) i += j(e[o]);
return i;
}
function P(e, t, n) {
for (var r = e.slice(t, n), i = "", o = 0; o < r.length; o += 2) i += String.fromCharCode(r[o] + 256 * r[o + 1]);
return i;
}
function B(e, t, n) {
if (e % 1 != 0 || e < 0) throw new RangeError("offset is not uint");
if (e + t > n) throw new RangeError("Trying to access beyond buffer length");
}
function D(e, t, n, r, i, o) {
if (!u.isBuffer(e)) throw new TypeError('"buffer" argument must be a Buffer instance');
if (t > i || t < o) throw new RangeError('"value" argument is out of bounds');
if (n + r > e.length) throw new RangeError("Index out of range");
}
function C(e, t, n, r) {
t < 0 && (t = 65535 + t + 1);
for (var i = 0, o = Math.min(e.length - n, 2); i < o; ++i) e[n + i] = (t & 255 << 8 * (r ? i : 1 - i)) >>> 8 * (r ? i : 1 - i);
}
function L(e, t, n, r) {
t < 0 && (t = 4294967295 + t + 1);
for (var i = 0, o = Math.min(e.length - n, 4); i < o; ++i) e[n + i] = t >>> 8 * (r ? i : 3 - i) & 255;
}
function x(e, t, n, r) {
if (n + r > e.length) throw new RangeError("Index out of range");
if (n < 0) throw new RangeError("Index out of range");
}
function k(e, t, n, r, o) {
return o || x(e, 0, n, 4), i.write(e, t, n, r, 23, 4), n + 4;
}
function U(e, t, n, r, o) {
return o || x(e, 0, n, 8), i.write(e, t, n, r, 52, 8), n + 8;
}
u.prototype.slice = function(e, t) {
var n, r = this.length;
if ((e = ~~e) < 0 ? (e += r) < 0 && (e = 0) : e > r && (e = r), (t = void 0 === t ? r : ~~t) < 0 ? (t += r) < 0 && (t = 0) : t > r && (t = r), 
t < e && (t = e), u.TYPED_ARRAY_SUPPORT) (n = this.subarray(e, t)).__proto__ = u.prototype; else {
var i = t - e;
n = new u(i, void 0);
for (var o = 0; o < i; ++o) n[o] = this[o + e];
}
return n;
}, u.prototype.readUIntLE = function(e, t, n) {
e |= 0, t |= 0, n || B(e, t, this.length);
for (var r = this[e], i = 1, o = 0; ++o < t && (i *= 256); ) r += this[e + o] * i;
return r;
}, u.prototype.readUIntBE = function(e, t, n) {
e |= 0, t |= 0, n || B(e, t, this.length);
for (var r = this[e + --t], i = 1; t > 0 && (i *= 256); ) r += this[e + --t] * i;
return r;
}, u.prototype.readUInt8 = function(e, t) {
return t || B(e, 1, this.length), this[e];
}, u.prototype.readUInt16LE = function(e, t) {
return t || B(e, 2, this.length), this[e] | this[e + 1] << 8;
}, u.prototype.readUInt16BE = function(e, t) {
return t || B(e, 2, this.length), this[e] << 8 | this[e + 1];
}, u.prototype.readUInt32LE = function(e, t) {
return t || B(e, 4, this.length), (this[e] | this[e + 1] << 8 | this[e + 2] << 16) + 16777216 * this[e + 3];
}, u.prototype.readUInt32BE = function(e, t) {
return t || B(e, 4, this.length), 16777216 * this[e] + (this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3]);
}, u.prototype.readIntLE = function(e, t, n) {
e |= 0, t |= 0, n || B(e, t, this.length);
for (var r = this[e], i = 1, o = 0; ++o < t && (i *= 256); ) r += this[e + o] * i;
return r >= (i *= 128) && (r -= Math.pow(2, 8 * t)), r;
}, u.prototype.readIntBE = function(e, t, n) {
e |= 0, t |= 0, n || B(e, t, this.length);
for (var r = t, i = 1, o = this[e + --r]; r > 0 && (i *= 256); ) o += this[e + --r] * i;
return o >= (i *= 128) && (o -= Math.pow(2, 8 * t)), o;
}, u.prototype.readInt8 = function(e, t) {
return t || B(e, 1, this.length), 128 & this[e] ? -1 * (255 - this[e] + 1) : this[e];
}, u.prototype.readInt16LE = function(e, t) {
t || B(e, 2, this.length);
var n = this[e] | this[e + 1] << 8;
return 32768 & n ? 4294901760 | n : n;
}, u.prototype.readInt16BE = function(e, t) {
t || B(e, 2, this.length);
var n = this[e + 1] | this[e] << 8;
return 32768 & n ? 4294901760 | n : n;
}, u.prototype.readInt32LE = function(e, t) {
return t || B(e, 4, this.length), this[e] | this[e + 1] << 8 | this[e + 2] << 16 | this[e + 3] << 24;
}, u.prototype.readInt32BE = function(e, t) {
return t || B(e, 4, this.length), this[e] << 24 | this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3];
}, u.prototype.readFloatLE = function(e, t) {
return t || B(e, 4, this.length), i.read(this, e, !0, 23, 4);
}, u.prototype.readFloatBE = function(e, t) {
return t || B(e, 4, this.length), i.read(this, e, !1, 23, 4);
}, u.prototype.readDoubleLE = function(e, t) {
return t || B(e, 8, this.length), i.read(this, e, !0, 52, 8);
}, u.prototype.readDoubleBE = function(e, t) {
return t || B(e, 8, this.length), i.read(this, e, !1, 52, 8);
}, u.prototype.writeUIntLE = function(e, t, n, r) {
(e = +e, t |= 0, n |= 0, r) || D(this, e, t, n, Math.pow(2, 8 * n) - 1, 0);
var i = 1, o = 0;
for (this[t] = 255 & e; ++o < n && (i *= 256); ) this[t + o] = e / i & 255;
return t + n;
}, u.prototype.writeUIntBE = function(e, t, n, r) {
(e = +e, t |= 0, n |= 0, r) || D(this, e, t, n, Math.pow(2, 8 * n) - 1, 0);
var i = n - 1, o = 1;
for (this[t + i] = 255 & e; --i >= 0 && (o *= 256); ) this[t + i] = e / o & 255;
return t + n;
}, u.prototype.writeUInt8 = function(e, t, n) {
return e = +e, t |= 0, n || D(this, e, t, 1, 255, 0), u.TYPED_ARRAY_SUPPORT || (e = Math.floor(e)), 
this[t] = 255 & e, t + 1;
}, u.prototype.writeUInt16LE = function(e, t, n) {
return e = +e, t |= 0, n || D(this, e, t, 2, 65535, 0), u.TYPED_ARRAY_SUPPORT ? (this[t] = 255 & e, 
this[t + 1] = e >>> 8) : C(this, e, t, !0), t + 2;
}, u.prototype.writeUInt16BE = function(e, t, n) {
return e = +e, t |= 0, n || D(this, e, t, 2, 65535, 0), u.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 8, 
this[t + 1] = 255 & e) : C(this, e, t, !1), t + 2;
}, u.prototype.writeUInt32LE = function(e, t, n) {
return e = +e, t |= 0, n || D(this, e, t, 4, 4294967295, 0), u.TYPED_ARRAY_SUPPORT ? (this[t + 3] = e >>> 24, 
this[t + 2] = e >>> 16, this[t + 1] = e >>> 8, this[t] = 255 & e) : L(this, e, t, !0), 
t + 4;
}, u.prototype.writeUInt32BE = function(e, t, n) {
return e = +e, t |= 0, n || D(this, e, t, 4, 4294967295, 0), u.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 24, 
this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = 255 & e) : L(this, e, t, !1), 
t + 4;
}, u.prototype.writeIntLE = function(e, t, n, r) {
if (e = +e, t |= 0, !r) {
var i = Math.pow(2, 8 * n - 1);
D(this, e, t, n, i - 1, -i);
}
var o = 0, s = 1, a = 0;
for (this[t] = 255 & e; ++o < n && (s *= 256); ) e < 0 && 0 === a && 0 !== this[t + o - 1] && (a = 1), 
this[t + o] = (e / s >> 0) - a & 255;
return t + n;
}, u.prototype.writeIntBE = function(e, t, n, r) {
if (e = +e, t |= 0, !r) {
var i = Math.pow(2, 8 * n - 1);
D(this, e, t, n, i - 1, -i);
}
var o = n - 1, s = 1, a = 0;
for (this[t + o] = 255 & e; --o >= 0 && (s *= 256); ) e < 0 && 0 === a && 0 !== this[t + o + 1] && (a = 1), 
this[t + o] = (e / s >> 0) - a & 255;
return t + n;
}, u.prototype.writeInt8 = function(e, t, n) {
return e = +e, t |= 0, n || D(this, e, t, 1, 127, -128), u.TYPED_ARRAY_SUPPORT || (e = Math.floor(e)), 
e < 0 && (e = 255 + e + 1), this[t] = 255 & e, t + 1;
}, u.prototype.writeInt16LE = function(e, t, n) {
return e = +e, t |= 0, n || D(this, e, t, 2, 32767, -32768), u.TYPED_ARRAY_SUPPORT ? (this[t] = 255 & e, 
this[t + 1] = e >>> 8) : C(this, e, t, !0), t + 2;
}, u.prototype.writeInt16BE = function(e, t, n) {
return e = +e, t |= 0, n || D(this, e, t, 2, 32767, -32768), u.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 8, 
this[t + 1] = 255 & e) : C(this, e, t, !1), t + 2;
}, u.prototype.writeInt32LE = function(e, t, n) {
return e = +e, t |= 0, n || D(this, e, t, 4, 2147483647, -2147483648), u.TYPED_ARRAY_SUPPORT ? (this[t] = 255 & e, 
this[t + 1] = e >>> 8, this[t + 2] = e >>> 16, this[t + 3] = e >>> 24) : L(this, e, t, !0), 
t + 4;
}, u.prototype.writeInt32BE = function(e, t, n) {
return e = +e, t |= 0, n || D(this, e, t, 4, 2147483647, -2147483648), e < 0 && (e = 4294967295 + e + 1), 
u.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, 
this[t + 3] = 255 & e) : L(this, e, t, !1), t + 4;
}, u.prototype.writeFloatLE = function(e, t, n) {
return k(this, e, t, !0, n);
}, u.prototype.writeFloatBE = function(e, t, n) {
return k(this, e, t, !1, n);
}, u.prototype.writeDoubleLE = function(e, t, n) {
return U(this, e, t, !0, n);
}, u.prototype.writeDoubleBE = function(e, t, n) {
return U(this, e, t, !1, n);
}, u.prototype.copy = function(e, t, n, r) {
if (n || (n = 0), r || 0 === r || (r = this.length), t >= e.length && (t = e.length), 
t || (t = 0), r > 0 && r < n && (r = n), r === n) return 0;
if (0 === e.length || 0 === this.length) return 0;
if (t < 0) throw new RangeError("targetStart out of bounds");
if (n < 0 || n >= this.length) throw new RangeError("sourceStart out of bounds");
if (r < 0) throw new RangeError("sourceEnd out of bounds");
r > this.length && (r = this.length), e.length - t < r - n && (r = e.length - t + n);
var i, o = r - n;
if (this === e && n < t && t < r) for (i = o - 1; i >= 0; --i) e[i + t] = this[i + n]; else if (o < 1e3 || !u.TYPED_ARRAY_SUPPORT) for (i = 0; i < o; ++i) e[i + t] = this[i + n]; else Uint8Array.prototype.set.call(e, this.subarray(n, n + o), t);
return o;
}, u.prototype.fill = function(e, t, n, r) {
if ("string" == typeof e) {
if ("string" == typeof t ? (r = t, t = 0, n = this.length) : "string" == typeof n && (r = n, 
n = this.length), 1 === e.length) {
var i = e.charCodeAt(0);
i < 256 && (e = i);
}
if (void 0 !== r && "string" != typeof r) throw new TypeError("encoding must be a string");
if ("string" == typeof r && !u.isEncoding(r)) throw new TypeError("Unknown encoding: " + r);
} else "number" == typeof e && (e &= 255);
if (t < 0 || this.length < t || this.length < n) throw new RangeError("Out of range index");
if (n <= t) return this;
var o;
if (t >>>= 0, n = void 0 === n ? this.length : n >>> 0, e || (e = 0), "number" == typeof e) for (o = t; o < n; ++o) this[o] = e; else {
var s = u.isBuffer(e) ? e : $(new u(e, r).toString()), a = s.length;
for (o = 0; o < n - t; ++o) this[o + t] = s[o % a];
}
return this;
};
var M = /[^+\/0-9A-Za-z-_]/g;
function j(e) {
return e < 16 ? "0" + e.toString(16) : e.toString(16);
}
function $(e, t) {
var n;
t = t || 1 / 0;
for (var r = e.length, i = null, o = [], s = 0; s < r; ++s) {
if ((n = e.charCodeAt(s)) > 55295 && n < 57344) {
if (!i) {
if (n > 56319) {
(t -= 3) > -1 && o.push(239, 191, 189);
continue;
}
if (s + 1 === r) {
(t -= 3) > -1 && o.push(239, 191, 189);
continue;
}
i = n;
continue;
}
if (n < 56320) {
(t -= 3) > -1 && o.push(239, 191, 189), i = n;
continue;
}
n = 65536 + (i - 55296 << 10 | n - 56320);
} else i && (t -= 3) > -1 && o.push(239, 191, 189);
if (i = null, n < 128) {
if ((t -= 1) < 0) break;
o.push(n);
} else if (n < 2048) {
if ((t -= 2) < 0) break;
o.push(n >> 6 | 192, 63 & n | 128);
} else if (n < 65536) {
if ((t -= 3) < 0) break;
o.push(n >> 12 | 224, n >> 6 & 63 | 128, 63 & n | 128);
} else {
if (!(n < 1114112)) throw new Error("Invalid code point");
if ((t -= 4) < 0) break;
o.push(n >> 18 | 240, n >> 12 & 63 | 128, n >> 6 & 63 | 128, 63 & n | 128);
}
}
return o;
}
function q(e) {
return r.toByteArray(function(e) {
if ((e = function(e) {
return e.trim ? e.trim() : e.replace(/^\s+|\s+$/g, "");
}(e).replace(M, "")).length < 2) return "";
for (;e.length % 4 != 0; ) e += "=";
return e;
}(e));
}
function F(e, t, n, r) {
for (var i = 0; i < r && !(i + n >= t.length || i >= e.length); ++i) t[i + n] = e[i];
return i;
}
}).call(this, n(8));
}, function(e, t, n) {
"use strict";
var r;
n.r(t), n.d(t, "StorageType", function() {
return r;
}), n.d(t, "AbstractSDKRequest", function() {
return i;
}), n.d(t, "AbstractStorage", function() {
return o;
}), n.d(t, "formatUrl", function() {
return s;
}), function(e) {
e.local = "local", e.none = "none", e.session = "session";
}(r || (r = {}));
var i = function() {}, o = function() {};
function s(e, t, n) {
void 0 === n && (n = {});
var r = /\?/.test(t), i = "";
for (var o in n) "" === i ? !r && (t += "?") : i += "&", i += o + "=" + encodeURIComponent(n[o]);
return /^http(s)?\:\/\//.test(t += i) ? t : "" + e + t;
}
}, function(e, t, n) {
"use strict";
var r = this && this.__importDefault || function(e) {
return e && e.__esModule ? e : {
default: e
};
};
Object.defineProperty(t, "__esModule", {
value: !0
}), t.sleep = t.printGroupLog = t.throwError = t.printInfo = t.printError = t.printWarn = t.execCallback = t.createPromiseCallback = t.removeParam = t.getHash = t.getQuery = t.toQueryString = t.createSign = t.formatUrl = t.genSeqId = t.isFormData = t.isInstanceOf = t.isNull = t.isPalinObject = t.isUndefined = t.isString = t.isArray = void 0;
var i = r(n(21)), o = r(n(24)), s = r(n(25)), a = n(9);
function u(e) {
var t = o.default.stringify(e);
return (t = (t = t.replace(/=+$/, "")).replace(/\+/g, "-")).replace(/\//g, "_");
}
t.isArray = function(e) {
return "[object Array]" === Object.prototype.toString.call(e);
}, t.isString = function(e) {
return "string" == typeof e;
}, t.isUndefined = function(e) {
return void 0 === e;
}, t.isPalinObject = function(e) {
return "[object Object]" === Object.prototype.toString.call(e);
}, t.isNull = function(e) {
return "[object Null]" === Object.prototype.toString.call(e);
}, t.isInstanceOf = function(e, t) {
return e instanceof t;
}, t.isFormData = function(e) {
return "[object FormData]" === Object.prototype.toString.call(e);
}, t.genSeqId = function() {
return Math.random().toString(16).slice(2);
}, t.formatUrl = function(e, t, n) {
void 0 === n && (n = {});
var r = /\?/.test(t), i = "";
for (var o in n) "" === i ? !r && (t += "?") : i += "&", i += o + "=" + encodeURIComponent(n[o]);
return /^http(s)?\:\/\//.test(t += i) ? t : "" + e + t;
}, t.createSign = function(e, t) {
var n = u(s.default.parse(JSON.stringify({
alg: "HS256",
typ: "JWT"
}))) + "." + u(s.default.parse(JSON.stringify(e)));
return n + "." + u(i.default(n, t));
}, t.toQueryString = function(e) {
void 0 === e && (e = {});
var t = [];
for (var n in e) t.push(n + "=" + encodeURIComponent(e[n]));
return t.join("&");
}, t.getQuery = function(e, t) {
if ("undefined" == typeof window) return !1;
var n = t || window.location.search, r = new RegExp("(^|&)" + e + "=([^&]*)(&|$)"), i = n.substr(n.indexOf("?") + 1).match(r);
return null != i ? i[2] : "";
}, t.getHash = function(e) {
if ("undefined" == typeof window) return "";
var t = window.location.hash.match(new RegExp("[#?&/]" + e + "=([^&#]*)"));
return t ? t[1] : "";
}, t.removeParam = function(e, t) {
var n = t.split("?")[0], r = [], i = -1 !== t.indexOf("?") ? t.split("?")[1] : "";
if ("" !== i) {
for (var o = (r = i.split("&")).length - 1; o >= 0; o -= 1) r[o].split("=")[0] === e && r.splice(o, 1);
n = n + "?" + r.join("&");
}
return n;
}, t.createPromiseCallback = function() {
var e;
if (!Promise) {
(e = function() {}).promise = {};
var t = function() {
throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.');
};
return Object.defineProperty(e.promise, "then", {
get: t
}), Object.defineProperty(e.promise, "catch", {
get: t
}), e;
}
var n = new Promise(function(t, n) {
e = function(e, r) {
return e ? n(e) : t(r);
};
});
return e.promise = n, e;
}, t.execCallback = function(e, t, n) {
if (void 0 === n && (n = null), e && "function" == typeof e) return e(t, n);
if (t) throw t;
return n;
}, t.printWarn = function(e, t) {
console.warn("[" + a.getSdkName() + "][" + e + "]:" + t);
}, t.printError = function(e, t) {
console.error({
code: e,
msg: "[" + a.getSdkName() + "][" + e + "]:" + t
});
}, t.printInfo = function(e, t) {
console.log("[" + a.getSdkName() + "][" + e + "]:" + t);
}, t.throwError = function(e, t) {
throw new Error(JSON.stringify({
code: e,
msg: "[" + a.getSdkName() + "][" + e + "]:" + t
}));
}, t.printGroupLog = function(e) {
var t = e.title, n = e.subtitle, r = void 0 === n ? "" : n, i = e.content, o = void 0 === i ? [] : i, s = e.printTrace, a = void 0 !== s && s, u = e.collapsed;
void 0 !== u && u ? console.groupCollapsed(t, r) : console.group(t, r);
for (var c = 0, f = o; c < f.length; c++) {
var l = f[c], h = l.type, p = l.body;
switch (h) {
case "info":
console.log(p);
break;

case "warn":
console.warn(p);
break;

case "error":
console.error(p);
}
}
a && console.trace("stack trace:"), console.groupEnd();
}, t.sleep = function(e) {
return void 0 === e && (e = 0), new Promise(function(t) {
return setTimeout(t, e);
});
};
}, function(e) {
e.exports = n;
var t = null;
try {
t = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([ 0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11 ])), {}).exports;
} catch (e) {}
function n(e, t, n) {
this.low = 0 | e, this.high = 0 | t, this.unsigned = !!n;
}
function r(e) {
return !0 === (e && e.__isLong__);
}
n.prototype.__isLong__, Object.defineProperty(n.prototype, "__isLong__", {
value: !0
}), n.isLong = r;
var i = {}, o = {};
function s(e, t) {
var n, r, s;
return t ? (s = 0 <= (e >>>= 0) && e < 256) && (r = o[e]) ? r : (n = u(e, (0 | e) < 0 ? -1 : 0, !0), 
s && (o[e] = n), n) : (s = -128 <= (e |= 0) && e < 128) && (r = i[e]) ? r : (n = u(e, e < 0 ? -1 : 0, !1), 
s && (i[e] = n), n);
}
function a(e, t) {
if (isNaN(e)) return t ? g : _;
if (t) {
if (e < 0) return g;
if (e >= p) return E;
} else {
if (e <= -d) return S;
if (e + 1 >= d) return w;
}
return e < 0 ? a(-e, t).neg() : u(e % h | 0, e / h | 0, t);
}
function u(e, t, r) {
return new n(e, t, r);
}
n.fromInt = s, n.fromNumber = a, n.fromBits = u;
var c = Math.pow;
function f(e, t, n) {
if (0 === e.length) throw Error("empty string");
if ("NaN" === e || "Infinity" === e || "+Infinity" === e || "-Infinity" === e) return _;
if ("number" == typeof t ? (n = t, t = !1) : t = !!t, (n = n || 10) < 2 || 36 < n) throw RangeError("radix");
var r;
if ((r = e.indexOf("-")) > 0) throw Error("interior hyphen");
if (0 === r) return f(e.substring(1), t, n).neg();
for (var i = a(c(n, 8)), o = _, s = 0; s < e.length; s += 8) {
var u = Math.min(8, e.length - s), l = parseInt(e.substring(s, s + u), n);
if (u < 8) {
var h = a(c(n, u));
o = o.mul(h).add(a(l));
} else o = (o = o.mul(i)).add(a(l));
}
return o.unsigned = t, o;
}
function l(e, t) {
return "number" == typeof e ? a(e, t) : "string" == typeof e ? f(e, t) : u(e.low, e.high, "boolean" == typeof t ? t : e.unsigned);
}
n.fromString = f, n.fromValue = l;
var h = 4294967296, p = h * h, d = p / 2, y = s(1 << 24), _ = s(0);
n.ZERO = _;
var g = s(0, !0);
n.UZERO = g;
var v = s(1);
n.ONE = v;
var m = s(1, !0);
n.UONE = m;
var b = s(-1);
n.NEG_ONE = b;
var w = u(-1, 2147483647, !1);
n.MAX_VALUE = w;
var E = u(-1, -1, !0);
n.MAX_UNSIGNED_VALUE = E;
var S = u(0, -2147483648, !1);
n.MIN_VALUE = S;
var A = n.prototype;
A.toInt = function() {
return this.unsigned ? this.low >>> 0 : this.low;
}, A.toNumber = function() {
return this.unsigned ? (this.high >>> 0) * h + (this.low >>> 0) : this.high * h + (this.low >>> 0);
}, A.toString = function(e) {
if ((e = e || 10) < 2 || 36 < e) throw RangeError("radix");
if (this.isZero()) return "0";
if (this.isNegative()) {
if (this.eq(S)) {
var t = a(e), n = this.div(t), r = n.mul(t).sub(this);
return n.toString(e) + r.toInt().toString(e);
}
return "-" + this.neg().toString(e);
}
for (var i = a(c(e, 6), this.unsigned), o = this, s = ""; ;) {
var u = o.div(i), f = (o.sub(u.mul(i)).toInt() >>> 0).toString(e);
if ((o = u).isZero()) return f + s;
for (;f.length < 6; ) f = "0" + f;
s = "" + f + s;
}
}, A.getHighBits = function() {
return this.high;
}, A.getHighBitsUnsigned = function() {
return this.high >>> 0;
}, A.getLowBits = function() {
return this.low;
}, A.getLowBitsUnsigned = function() {
return this.low >>> 0;
}, A.getNumBitsAbs = function() {
if (this.isNegative()) return this.eq(S) ? 64 : this.neg().getNumBitsAbs();
for (var e = 0 != this.high ? this.high : this.low, t = 31; t > 0 && 0 == (e & 1 << t); t--) ;
return 0 != this.high ? t + 33 : t + 1;
}, A.isZero = function() {
return 0 === this.high && 0 === this.low;
}, A.eqz = A.isZero, A.isNegative = function() {
return !this.unsigned && this.high < 0;
}, A.isPositive = function() {
return this.unsigned || this.high >= 0;
}, A.isOdd = function() {
return 1 == (1 & this.low);
}, A.isEven = function() {
return 0 == (1 & this.low);
}, A.equals = function(e) {
return r(e) || (e = l(e)), (this.unsigned === e.unsigned || this.high >>> 31 != 1 || e.high >>> 31 != 1) && this.high === e.high && this.low === e.low;
}, A.eq = A.equals, A.notEquals = function(e) {
return !this.eq(e);
}, A.neq = A.notEquals, A.ne = A.notEquals, A.lessThan = function(e) {
return this.comp(e) < 0;
}, A.lt = A.lessThan, A.lessThanOrEqual = function(e) {
return this.comp(e) <= 0;
}, A.lte = A.lessThanOrEqual, A.le = A.lessThanOrEqual, A.greaterThan = function(e) {
return this.comp(e) > 0;
}, A.gt = A.greaterThan, A.greaterThanOrEqual = function(e) {
return this.comp(e) >= 0;
}, A.gte = A.greaterThanOrEqual, A.ge = A.greaterThanOrEqual, A.compare = function(e) {
if (r(e) || (e = l(e)), this.eq(e)) return 0;
var t = this.isNegative(), n = e.isNegative();
return t && !n ? -1 : !t && n ? 1 : this.unsigned ? e.high >>> 0 > this.high >>> 0 || e.high === this.high && e.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(e).isNegative() ? -1 : 1;
}, A.comp = A.compare, A.negate = function() {
return !this.unsigned && this.eq(S) ? S : this.not().add(v);
}, A.neg = A.negate, A.add = function(e) {
r(e) || (e = l(e));
var t = this.high >>> 16, n = 65535 & this.high, i = this.low >>> 16, o = 65535 & this.low, s = e.high >>> 16, a = 65535 & e.high, c = e.low >>> 16, f = 0, h = 0, p = 0, d = 0;
return p += (d += o + (65535 & e.low)) >>> 16, h += (p += i + c) >>> 16, f += (h += n + a) >>> 16, 
f += t + s, u((p &= 65535) << 16 | (d &= 65535), (f &= 65535) << 16 | (h &= 65535), this.unsigned);
}, A.subtract = function(e) {
return r(e) || (e = l(e)), this.add(e.neg());
}, A.sub = A.subtract, A.multiply = function(e) {
if (this.isZero()) return _;
if (r(e) || (e = l(e)), t) return u(t.mul(this.low, this.high, e.low, e.high), t.get_high(), this.unsigned);
if (e.isZero()) return _;
if (this.eq(S)) return e.isOdd() ? S : _;
if (e.eq(S)) return this.isOdd() ? S : _;
if (this.isNegative()) return e.isNegative() ? this.neg().mul(e.neg()) : this.neg().mul(e).neg();
if (e.isNegative()) return this.mul(e.neg()).neg();
if (this.lt(y) && e.lt(y)) return a(this.toNumber() * e.toNumber(), this.unsigned);
var n = this.high >>> 16, i = 65535 & this.high, o = this.low >>> 16, s = 65535 & this.low, c = e.high >>> 16, f = 65535 & e.high, h = e.low >>> 16, p = 65535 & e.low, d = 0, g = 0, v = 0, m = 0;
return v += (m += s * p) >>> 16, g += (v += o * p) >>> 16, v &= 65535, g += (v += s * h) >>> 16, 
d += (g += i * p) >>> 16, g &= 65535, d += (g += o * h) >>> 16, g &= 65535, d += (g += s * f) >>> 16, 
d += n * p + i * h + o * f + s * c, u((v &= 65535) << 16 | (m &= 65535), (d &= 65535) << 16 | (g &= 65535), this.unsigned);
}, A.mul = A.multiply, A.divide = function(e) {
if (r(e) || (e = l(e)), e.isZero()) throw Error("division by zero");
var n, i, o;
if (t) return this.unsigned || -2147483648 !== this.high || -1 !== e.low || -1 !== e.high ? u((this.unsigned ? t.div_u : t.div_s)(this.low, this.high, e.low, e.high), t.get_high(), this.unsigned) : this;
if (this.isZero()) return this.unsigned ? g : _;
if (this.unsigned) {
if (e.unsigned || (e = e.toUnsigned()), e.gt(this)) return g;
if (e.gt(this.shru(1))) return m;
o = g;
} else {
if (this.eq(S)) return e.eq(v) || e.eq(b) ? S : e.eq(S) ? v : (n = this.shr(1).div(e).shl(1)).eq(_) ? e.isNegative() ? v : b : (i = this.sub(e.mul(n)), 
o = n.add(i.div(e)));
if (e.eq(S)) return this.unsigned ? g : _;
if (this.isNegative()) return e.isNegative() ? this.neg().div(e.neg()) : this.neg().div(e).neg();
if (e.isNegative()) return this.div(e.neg()).neg();
o = _;
}
for (i = this; i.gte(e); ) {
n = Math.max(1, Math.floor(i.toNumber() / e.toNumber()));
for (var s = Math.ceil(Math.log(n) / Math.LN2), f = s <= 48 ? 1 : c(2, s - 48), h = a(n), p = h.mul(e); p.isNegative() || p.gt(i); ) p = (h = a(n -= f, this.unsigned)).mul(e);
h.isZero() && (h = v), o = o.add(h), i = i.sub(p);
}
return o;
}, A.div = A.divide, A.modulo = function(e) {
return r(e) || (e = l(e)), t ? u((this.unsigned ? t.rem_u : t.rem_s)(this.low, this.high, e.low, e.high), t.get_high(), this.unsigned) : this.sub(this.div(e).mul(e));
}, A.mod = A.modulo, A.rem = A.modulo, A.not = function() {
return u(~this.low, ~this.high, this.unsigned);
}, A.and = function(e) {
return r(e) || (e = l(e)), u(this.low & e.low, this.high & e.high, this.unsigned);
}, A.or = function(e) {
return r(e) || (e = l(e)), u(this.low | e.low, this.high | e.high, this.unsigned);
}, A.xor = function(e) {
return r(e) || (e = l(e)), u(this.low ^ e.low, this.high ^ e.high, this.unsigned);
}, A.shiftLeft = function(e) {
return r(e) && (e = e.toInt()), 0 == (e &= 63) ? this : e < 32 ? u(this.low << e, this.high << e | this.low >>> 32 - e, this.unsigned) : u(0, this.low << e - 32, this.unsigned);
}, A.shl = A.shiftLeft, A.shiftRight = function(e) {
return r(e) && (e = e.toInt()), 0 == (e &= 63) ? this : e < 32 ? u(this.low >>> e | this.high << 32 - e, this.high >> e, this.unsigned) : u(this.high >> e - 32, this.high >= 0 ? 0 : -1, this.unsigned);
}, A.shr = A.shiftRight, A.shiftRightUnsigned = function(e) {
if (r(e) && (e = e.toInt()), 0 == (e &= 63)) return this;
var t = this.high;
return e < 32 ? u(this.low >>> e | t << 32 - e, t >>> e, this.unsigned) : u(32 === e ? t : t >>> e - 32, 0, this.unsigned);
}, A.shru = A.shiftRightUnsigned, A.shr_u = A.shiftRightUnsigned, A.toSigned = function() {
return this.unsigned ? u(this.low, this.high, !1) : this;
}, A.toUnsigned = function() {
return this.unsigned ? this : u(this.low, this.high, !0);
}, A.toBytes = function(e) {
return e ? this.toBytesLE() : this.toBytesBE();
}, A.toBytesLE = function() {
var e = this.high, t = this.low;
return [ 255 & t, t >>> 8 & 255, t >>> 16 & 255, t >>> 24, 255 & e, e >>> 8 & 255, e >>> 16 & 255, e >>> 24 ];
}, A.toBytesBE = function() {
var e = this.high, t = this.low;
return [ e >>> 24, e >>> 16 & 255, e >>> 8 & 255, 255 & e, t >>> 24, t >>> 16 & 255, t >>> 8 & 255, 255 & t ];
}, n.fromBytes = function(e, t, r) {
return r ? n.fromBytesLE(e, t) : n.fromBytesBE(e, t);
}, n.fromBytesLE = function(e, t) {
return new n(e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24, e[4] | e[5] << 8 | e[6] << 16 | e[7] << 24, t);
}, n.fromBytesBE = function(e, t) {
return new n(e[4] << 24 | e[5] << 16 | e[6] << 8 | e[7], e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3], t);
};
}, function(e) {
var t;
e.exports = t = t || function(e) {
var t = Object.create || function() {
function e() {}
return function(t) {
var n;
return e.prototype = t, n = new e(), e.prototype = null, n;
};
}(), n = {}, r = n.lib = {}, i = r.Base = {
extend: function(e) {
var n = t(this);
return e && n.mixIn(e), n.hasOwnProperty("init") && this.init !== n.init || (n.init = function() {
n.$super.init.apply(this, arguments);
}), n.init.prototype = n, n.$super = this, n;
},
create: function() {
var e = this.extend();
return e.init.apply(e, arguments), e;
},
init: function() {},
mixIn: function(e) {
for (var t in e) e.hasOwnProperty(t) && (this[t] = e[t]);
e.hasOwnProperty("toString") && (this.toString = e.toString);
},
clone: function() {
return this.init.prototype.extend(this);
}
}, o = r.WordArray = i.extend({
init: function(e, t) {
e = this.words = e || [], this.sigBytes = null != t ? t : 4 * e.length;
},
toString: function(e) {
return (e || a).stringify(this);
},
concat: function(e) {
var t = this.words, n = e.words, r = this.sigBytes, i = e.sigBytes;
if (this.clamp(), r % 4) for (var o = 0; o < i; o++) {
var s = n[o >>> 2] >>> 24 - o % 4 * 8 & 255;
t[r + o >>> 2] |= s << 24 - (r + o) % 4 * 8;
} else for (o = 0; o < i; o += 4) t[r + o >>> 2] = n[o >>> 2];
return this.sigBytes += i, this;
},
clamp: function() {
var t = this.words, n = this.sigBytes;
t[n >>> 2] &= 4294967295 << 32 - n % 4 * 8, t.length = e.ceil(n / 4);
},
clone: function() {
var e = i.clone.call(this);
return e.words = this.words.slice(0), e;
},
random: function(t) {
for (var n, r = [], i = function(t) {
t = t;
var n = 987654321, r = 4294967295;
return function() {
var i = ((n = 36969 * (65535 & n) + (n >> 16) & r) << 16) + (t = 18e3 * (65535 & t) + (t >> 16) & r) & r;
return i /= 4294967296, (i += .5) * (e.random() > .5 ? 1 : -1);
};
}, s = 0; s < t; s += 4) {
var a = i(4294967296 * (n || e.random()));
n = 987654071 * a(), r.push(4294967296 * a() | 0);
}
return new o.init(r, t);
}
}), s = n.enc = {}, a = s.Hex = {
stringify: function(e) {
for (var t = e.words, n = e.sigBytes, r = [], i = 0; i < n; i++) {
var o = t[i >>> 2] >>> 24 - i % 4 * 8 & 255;
r.push((o >>> 4).toString(16)), r.push((15 & o).toString(16));
}
return r.join("");
},
parse: function(e) {
for (var t = e.length, n = [], r = 0; r < t; r += 2) n[r >>> 3] |= parseInt(e.substr(r, 2), 16) << 24 - r % 8 * 4;
return new o.init(n, t / 2);
}
}, u = s.Latin1 = {
stringify: function(e) {
for (var t = e.words, n = e.sigBytes, r = [], i = 0; i < n; i++) {
var o = t[i >>> 2] >>> 24 - i % 4 * 8 & 255;
r.push(String.fromCharCode(o));
}
return r.join("");
},
parse: function(e) {
for (var t = e.length, n = [], r = 0; r < t; r++) n[r >>> 2] |= (255 & e.charCodeAt(r)) << 24 - r % 4 * 8;
return new o.init(n, t);
}
}, c = s.Utf8 = {
stringify: function(e) {
try {
return decodeURIComponent(escape(u.stringify(e)));
} catch (e) {
throw new Error("Malformed UTF-8 data");
}
},
parse: function(e) {
return u.parse(unescape(encodeURIComponent(e)));
}
}, f = r.BufferedBlockAlgorithm = i.extend({
reset: function() {
this._data = new o.init(), this._nDataBytes = 0;
},
_append: function(e) {
"string" == typeof e && (e = c.parse(e)), this._data.concat(e), this._nDataBytes += e.sigBytes;
},
_process: function(t) {
var n = this._data, r = n.words, i = n.sigBytes, s = this.blockSize, a = i / (4 * s), u = (a = t ? e.ceil(a) : e.max((0 | a) - this._minBufferSize, 0)) * s, c = e.min(4 * u, i);
if (u) {
for (var f = 0; f < u; f += s) this._doProcessBlock(r, f);
var l = r.splice(0, u);
n.sigBytes -= c;
}
return new o.init(l, c);
},
clone: function() {
var e = i.clone.call(this);
return e._data = this._data.clone(), e;
},
_minBufferSize: 0
}), l = (r.Hasher = f.extend({
cfg: i.extend(),
init: function(e) {
this.cfg = this.cfg.extend(e), this.reset();
},
reset: function() {
f.reset.call(this), this._doReset();
},
update: function(e) {
return this._append(e), this._process(), this;
},
finalize: function(e) {
return e && this._append(e), this._doFinalize();
},
blockSize: 16,
_createHelper: function(e) {
return function(t, n) {
return new e.init(n).finalize(t);
};
},
_createHmacHelper: function(e) {
return function(t, n) {
return new l.HMAC.init(e, n).finalize(t);
};
}
}), n.algo = {});
return n;
}(Math);
}, function(e) {
var t;
t = function() {
return this;
}();
try {
t = t || new Function("return this")();
} catch (e) {
"object" == typeof window && (t = window);
}
e.exports = t;
}, function(e, t, n) {
"use strict";
var r = this && this.__createBinding || (Object.create ? function(e, t, n, r) {
void 0 === r && (r = n), Object.defineProperty(e, r, {
enumerable: !0,
get: function() {
return t[n];
}
});
} : function(e, t, n, r) {
void 0 === r && (r = n), e[r] = t[n];
}), i = this && this.__exportStar || function(e, t) {
for (var n in e) "default" === n || t.hasOwnProperty(n) || r(t, e, n);
};
Object.defineProperty(t, "__esModule", {
value: !0
}), i(n(10), t), i(n(18), t);
}, function(e, t) {
"use strict";
Object.defineProperty(t, "__esModule", {
value: !0
}), t.COMMUNITY_SITE_URL = t.IS_DEBUG_MODE = t.getProtocol = t.setProtocol = t.getSdkName = t.setSdkName = void 0;
var n = "@cloudbase/js-sdk";
t.setSdkName = function(e) {
n = e;
}, t.getSdkName = function() {
return n;
};
var r = "undefined" != typeof location && "http:" === location.protocol ? "http:" : "https:";
t.setProtocol = function(e) {
r = e;
}, t.getProtocol = function() {
return r;
}, t.IS_DEBUG_MODE = !1, t.COMMUNITY_SITE_URL = "https://support.qq.com/products/148793";
}, function(e) {
var t, n, r = e.exports = {};
function i() {
throw new Error("setTimeout has not been defined");
}
function o() {
throw new Error("clearTimeout has not been defined");
}
function s(e) {
if (t === setTimeout) return setTimeout(e, 0);
if ((t === i || !t) && setTimeout) return t = setTimeout, setTimeout(e, 0);
try {
return t(e, 0);
} catch (n) {
try {
return t.call(null, e, 0);
} catch (n) {
return t.call(this, e, 0);
}
}
}
!function() {
try {
t = "function" == typeof setTimeout ? setTimeout : i;
} catch (e) {
t = i;
}
try {
n = "function" == typeof clearTimeout ? clearTimeout : o;
} catch (e) {
n = o;
}
}();
var a, u = [], c = !1, f = -1;
function l() {
c && a && (c = !1, a.length ? u = a.concat(u) : f = -1, u.length && h());
}
function h() {
if (!c) {
var e = s(l);
c = !0;
for (var t = u.length; t; ) {
for (a = u, u = []; ++f < t; ) a && a[f].run();
f = -1, t = u.length;
}
a = null, c = !1, function(e) {
if (n === clearTimeout) return clearTimeout(e);
if ((n === o || !n) && clearTimeout) return n = clearTimeout, clearTimeout(e);
try {
n(e);
} catch (t) {
try {
return n.call(null, e);
} catch (t) {
return n.call(this, e);
}
}
}(e);
}
}
function p(e, t) {
this.fun = e, this.array = t;
}
function d() {}
r.nextTick = function(e) {
var t = new Array(arguments.length - 1);
if (arguments.length > 1) for (var n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
u.push(new p(e, t)), 1 !== u.length || c || s(h);
}, p.prototype.run = function() {
this.fun.apply(null, this.array);
}, r.title = "browser", r.browser = !0, r.env = {}, r.argv = [], r.version = "", 
r.versions = {}, r.on = d, r.addListener = d, r.once = d, r.off = d, r.removeListener = d, 
r.removeAllListeners = d, r.emit = d, r.prependListener = d, r.prependOnceListener = d, 
r.listeners = function() {
return [];
}, r.binding = function() {
throw new Error("process.binding is not supported");
}, r.cwd = function() {
return "/";
}, r.chdir = function() {
throw new Error("process.chdir is not supported");
}, r.umask = function() {
return 0;
};
}, function(e, t, n) {
(function(t) {
var n, r = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, i = /^\w*$/, o = /^\./, s = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, a = /\\(\\)?/g, u = /^\[object .+?Constructor\]$/, c = /^(?:0|[1-9]\d*)$/, f = "object" == typeof t && t && t.Object === Object && t, l = "object" == typeof self && self && self.Object === Object && self, h = f || l || Function("", "return this")(), p = Array.prototype, d = Function.prototype, y = Object.prototype, _ = h["__core-js_shared__"], g = (n = /[^.]+$/.exec(_ && _.keys && _.keys.IE_PROTO || "")) ? "Symbol(src)_1." + n : "", v = d.toString, m = y.hasOwnProperty, b = y.toString, w = RegExp("^" + v.call(m).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"), E = h.Symbol, S = p.splice, A = k(h, "Map"), O = k(Object, "create"), I = E ? E.prototype : void 0, T = I ? I.toString : void 0;
function N(e) {
var t = -1, n = e ? e.length : 0;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
function R(e) {
var t = -1, n = e ? e.length : 0;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
function P(e) {
var t = -1, n = e ? e.length : 0;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
function B(e, t, n) {
var r = e[t];
m.call(e, t) && q(r, n) && (void 0 !== n || t in e) || (e[t] = n);
}
function D(e, t) {
for (var n = e.length; n--; ) if (q(e[n][0], t)) return n;
return -1;
}
function C(e) {
return !(!W(e) || (t = e, g && g in t)) && (function(e) {
var t = W(e) ? b.call(e) : "";
return "[object Function]" == t || "[object GeneratorFunction]" == t;
}(e) || function(e) {
var t = !1;
if (null != e && "function" != typeof e.toString) try {
t = !!(e + "");
} catch (e) {}
return t;
}(e) ? w : u).test(function(e) {
if (null != e) {
try {
return v.call(e);
} catch (e) {}
try {
return e + "";
} catch (e) {}
}
return "";
}(e));
var t;
}
function L(e, t, n, o) {
if (!W(e)) return e;
for (var s = -1, a = (t = function(e, t) {
if (F(e)) return !1;
var n = typeof e;
return !("number" != n && "symbol" != n && "boolean" != n && null != e && !z(e)) || i.test(e) || !r.test(e) || null != t && e in Object(t);
}(t, e) ? [ t ] : function(e) {
return F(e) ? e : M(e);
}(t)).length, u = a - 1, c = e; null != c && ++s < a; ) {
var f = j(t[s]), l = n;
if (s != u) {
var h = c[f];
void 0 === (l = o ? o(h, f, c) : void 0) && (l = W(h) ? h : U(t[s + 1]) ? [] : {});
}
B(c, f, l), c = c[f];
}
return e;
}
function x(e, t) {
var n, r, i = e.__data__;
return ("string" == (r = typeof (n = t)) || "number" == r || "symbol" == r || "boolean" == r ? "__proto__" !== n : null === n) ? i["string" == typeof t ? "string" : "hash"] : i.map;
}
function k(e, t) {
var n = function(e, t) {
return null == e ? void 0 : e[t];
}(e, t);
return C(n) ? n : void 0;
}
function U(e, t) {
return !!(t = null == t ? 9007199254740991 : t) && ("number" == typeof e || c.test(e)) && e > -1 && e % 1 == 0 && e < t;
}
N.prototype.clear = function() {
this.__data__ = O ? O(null) : {};
}, N.prototype.delete = function(e) {
return this.has(e) && delete this.__data__[e];
}, N.prototype.get = function(e) {
var t = this.__data__;
if (O) {
var n = t[e];
return "__lodash_hash_undefined__" === n ? void 0 : n;
}
return m.call(t, e) ? t[e] : void 0;
}, N.prototype.has = function(e) {
var t = this.__data__;
return O ? void 0 !== t[e] : m.call(t, e);
}, N.prototype.set = function(e, t) {
return this.__data__[e] = O && void 0 === t ? "__lodash_hash_undefined__" : t, this;
}, R.prototype.clear = function() {
this.__data__ = [];
}, R.prototype.delete = function(e) {
var t = this.__data__, n = D(t, e);
return !(n < 0 || (n == t.length - 1 ? t.pop() : S.call(t, n, 1), 0));
}, R.prototype.get = function(e) {
var t = this.__data__, n = D(t, e);
return n < 0 ? void 0 : t[n][1];
}, R.prototype.has = function(e) {
return D(this.__data__, e) > -1;
}, R.prototype.set = function(e, t) {
var n = this.__data__, r = D(n, e);
return r < 0 ? n.push([ e, t ]) : n[r][1] = t, this;
}, P.prototype.clear = function() {
this.__data__ = {
hash: new N(),
map: new (A || R)(),
string: new N()
};
}, P.prototype.delete = function(e) {
return x(this, e).delete(e);
}, P.prototype.get = function(e) {
return x(this, e).get(e);
}, P.prototype.has = function(e) {
return x(this, e).has(e);
}, P.prototype.set = function(e, t) {
return x(this, e).set(e, t), this;
};
var M = $(function(e) {
var t;
e = null == (t = e) ? "" : function(e) {
if ("string" == typeof e) return e;
if (z(e)) return T ? T.call(e) : "";
var t = e + "";
return "0" == t && 1 / e == -1 / 0 ? "-0" : t;
}(t);
var n = [];
return o.test(e) && n.push(""), e.replace(s, function(e, t, r, i) {
n.push(r ? i.replace(a, "$1") : t || e);
}), n;
});
function j(e) {
if ("string" == typeof e || z(e)) return e;
var t = e + "";
return "0" == t && 1 / e == -1 / 0 ? "-0" : t;
}
function $(e, t) {
if ("function" != typeof e || t && "function" != typeof t) throw new TypeError("Expected a function");
var n = function() {
var r = arguments, i = t ? t.apply(this, r) : r[0], o = n.cache;
if (o.has(i)) return o.get(i);
var s = e.apply(this, r);
return n.cache = o.set(i, s), s;
};
return n.cache = new ($.Cache || P)(), n;
}
function q(e, t) {
return e === t || e != e && t != t;
}
$.Cache = P;
var F = Array.isArray;
function W(e) {
var t = typeof e;
return !!e && ("object" == t || "function" == t);
}
function z(e) {
return "symbol" == typeof e || function(e) {
return !!e && "object" == typeof e;
}(e) && "[object Symbol]" == b.call(e);
}
e.exports = function(e, t, n) {
return null == e ? e : L(e, t, n);
};
}).call(this, n(8));
}, function(e, t, n) {
(function(t) {
var n, r = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, i = /^\w*$/, o = /^\./, s = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, a = /\\(\\)?/g, u = /^\[object .+?Constructor\]$/, c = "object" == typeof t && t && t.Object === Object && t, f = "object" == typeof self && self && self.Object === Object && self, l = c || f || Function("", "return this")(), h = Array.prototype, p = Function.prototype, d = Object.prototype, y = l["__core-js_shared__"], _ = (n = /[^.]+$/.exec(y && y.keys && y.keys.IE_PROTO || "")) ? "Symbol(src)_1." + n : "", g = p.toString, v = d.hasOwnProperty, m = d.toString, b = RegExp("^" + g.call(v).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"), w = l.Symbol, E = h.splice, S = x(l, "Map"), A = x(Object, "create"), O = w ? w.prototype : void 0, I = O ? O.toString : void 0;
function T(e) {
var t = -1, n = e ? e.length : 0;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
function N(e) {
var t = -1, n = e ? e.length : 0;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
function R(e) {
var t = -1, n = e ? e.length : 0;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
function P(e, t) {
for (var n, r, i = e.length; i--; ) if ((n = e[i][0]) === (r = t) || n != n && r != r) return i;
return -1;
}
function B(e) {
return !(!q(e) || (t = e, _ && _ in t)) && (function(e) {
var t = q(e) ? m.call(e) : "";
return "[object Function]" == t || "[object GeneratorFunction]" == t;
}(e) || function(e) {
var t = !1;
if (null != e && "function" != typeof e.toString) try {
t = !!(e + "");
} catch (e) {}
return t;
}(e) ? b : u).test(function(e) {
if (null != e) {
try {
return g.call(e);
} catch (e) {}
try {
return e + "";
} catch (e) {}
}
return "";
}(e));
var t;
}
function D(e, t) {
e = function(e, t) {
return 1 == t.length ? e : function(e, t) {
for (var n = 0, r = (t = k(t, e) ? [ t ] : C(t)).length; null != e && n < r; ) e = e[M(t[n++])];
return n && n == r ? e : void 0;
}(e, function(e, t, n) {
var r = -1, i = e.length;
t < 0 && (t = -t > i ? 0 : i + t), (n = n > i ? i : n) < 0 && (n += i), i = t > n ? 0 : n - t >>> 0, 
t >>>= 0;
for (var o = Array(i); ++r < i; ) o[r] = e[r + t];
return o;
}(t, 0, -1));
}(e, t = k(t, e) ? [ t ] : C(t));
var n, r, i = M((r = (n = t) ? n.length : 0) ? n[r - 1] : void 0);
return !(null != e && v.call(e, i)) || delete e[i];
}
function C(e) {
return $(e) ? e : U(e);
}
function L(e, t) {
var n, r, i = e.__data__;
return ("string" == (r = typeof (n = t)) || "number" == r || "symbol" == r || "boolean" == r ? "__proto__" !== n : null === n) ? i["string" == typeof t ? "string" : "hash"] : i.map;
}
function x(e, t) {
var n = function(e, t) {
return null == e ? void 0 : e[t];
}(e, t);
return B(n) ? n : void 0;
}
function k(e, t) {
if ($(e)) return !1;
var n = typeof e;
return !("number" != n && "symbol" != n && "boolean" != n && null != e && !F(e)) || i.test(e) || !r.test(e) || null != t && e in Object(t);
}
T.prototype.clear = function() {
this.__data__ = A ? A(null) : {};
}, T.prototype.delete = function(e) {
return this.has(e) && delete this.__data__[e];
}, T.prototype.get = function(e) {
var t = this.__data__;
if (A) {
var n = t[e];
return "__lodash_hash_undefined__" === n ? void 0 : n;
}
return v.call(t, e) ? t[e] : void 0;
}, T.prototype.has = function(e) {
var t = this.__data__;
return A ? void 0 !== t[e] : v.call(t, e);
}, T.prototype.set = function(e, t) {
return this.__data__[e] = A && void 0 === t ? "__lodash_hash_undefined__" : t, this;
}, N.prototype.clear = function() {
this.__data__ = [];
}, N.prototype.delete = function(e) {
var t = this.__data__, n = P(t, e);
return !(n < 0 || (n == t.length - 1 ? t.pop() : E.call(t, n, 1), 0));
}, N.prototype.get = function(e) {
var t = this.__data__, n = P(t, e);
return n < 0 ? void 0 : t[n][1];
}, N.prototype.has = function(e) {
return P(this.__data__, e) > -1;
}, N.prototype.set = function(e, t) {
var n = this.__data__, r = P(n, e);
return r < 0 ? n.push([ e, t ]) : n[r][1] = t, this;
}, R.prototype.clear = function() {
this.__data__ = {
hash: new T(),
map: new (S || N)(),
string: new T()
};
}, R.prototype.delete = function(e) {
return L(this, e).delete(e);
}, R.prototype.get = function(e) {
return L(this, e).get(e);
}, R.prototype.has = function(e) {
return L(this, e).has(e);
}, R.prototype.set = function(e, t) {
return L(this, e).set(e, t), this;
};
var U = j(function(e) {
var t;
e = null == (t = e) ? "" : function(e) {
if ("string" == typeof e) return e;
if (F(e)) return I ? I.call(e) : "";
var t = e + "";
return "0" == t && 1 / e == -1 / 0 ? "-0" : t;
}(t);
var n = [];
return o.test(e) && n.push(""), e.replace(s, function(e, t, r, i) {
n.push(r ? i.replace(a, "$1") : t || e);
}), n;
});
function M(e) {
if ("string" == typeof e || F(e)) return e;
var t = e + "";
return "0" == t && 1 / e == -1 / 0 ? "-0" : t;
}
function j(e, t) {
if ("function" != typeof e || t && "function" != typeof t) throw new TypeError("Expected a function");
var n = function() {
var r = arguments, i = t ? t.apply(this, r) : r[0], o = n.cache;
if (o.has(i)) return o.get(i);
var s = e.apply(this, r);
return n.cache = o.set(i, s), s;
};
return n.cache = new (j.Cache || R)(), n;
}
j.Cache = R;
var $ = Array.isArray;
function q(e) {
var t = typeof e;
return !!e && ("object" == t || "function" == t);
}
function F(e) {
return "symbol" == typeof e || function(e) {
return !!e && "object" == typeof e;
}(e) && "[object Symbol]" == m.call(e);
}
e.exports = function(e, t) {
return null == e || D(e, t);
};
}).call(this, n(8));
}, function(e, t, n) {
(function(e, n) {
var r = "[object Arguments]", i = "[object Function]", o = "[object GeneratorFunction]", s = "[object Map]", a = "[object Set]", u = /\w*$/, c = /^\[object .+?Constructor\]$/, f = /^(?:0|[1-9]\d*)$/, l = {};
l[r] = l["[object Array]"] = l["[object ArrayBuffer]"] = l["[object DataView]"] = l["[object Boolean]"] = l["[object Date]"] = l["[object Float32Array]"] = l["[object Float64Array]"] = l["[object Int8Array]"] = l["[object Int16Array]"] = l["[object Int32Array]"] = l[s] = l["[object Number]"] = l["[object Object]"] = l["[object RegExp]"] = l[a] = l["[object String]"] = l["[object Symbol]"] = l["[object Uint8Array]"] = l["[object Uint8ClampedArray]"] = l["[object Uint16Array]"] = l["[object Uint32Array]"] = !0, 
l["[object Error]"] = l[i] = l["[object WeakMap]"] = !1;
var h = "object" == typeof e && e && e.Object === Object && e, p = "object" == typeof self && self && self.Object === Object && self, d = h || p || Function("", "return this")(), y = t && !t.nodeType && t, _ = y && "object" == typeof n && n && !n.nodeType && n, g = _ && _.exports === y;
function v(e, t) {
return e.set(t[0], t[1]), e;
}
function m(e, t) {
return e.add(t), e;
}
function b(e, t, n, r) {
var i = -1, o = e ? e.length : 0;
for (r && o && (n = e[++i]); ++i < o; ) n = t(n, e[i], i, e);
return n;
}
function w(e) {
var t = !1;
if (null != e && "function" != typeof e.toString) try {
t = !!(e + "");
} catch (e) {}
return t;
}
function E(e) {
var t = -1, n = Array(e.size);
return e.forEach(function(e, r) {
n[++t] = [ r, e ];
}), n;
}
function S(e, t) {
return function(n) {
return e(t(n));
};
}
function A(e) {
var t = -1, n = Array(e.size);
return e.forEach(function(e) {
n[++t] = e;
}), n;
}
var O, I = Array.prototype, T = Function.prototype, N = Object.prototype, R = d["__core-js_shared__"], P = (O = /[^.]+$/.exec(R && R.keys && R.keys.IE_PROTO || "")) ? "Symbol(src)_1." + O : "", B = T.toString, D = N.hasOwnProperty, C = N.toString, L = RegExp("^" + B.call(D).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"), x = g ? d.Buffer : void 0, k = d.Symbol, U = d.Uint8Array, M = S(Object.getPrototypeOf, Object), j = Object.create, $ = N.propertyIsEnumerable, q = I.splice, F = Object.getOwnPropertySymbols, W = x ? x.isBuffer : void 0, z = S(Object.keys, Object), K = _e(d, "DataView"), G = _e(d, "Map"), Y = _e(d, "Promise"), H = _e(d, "Set"), J = _e(d, "WeakMap"), V = _e(Object, "create"), X = we(K), Q = we(G), Z = we(Y), ee = we(H), te = we(J), ne = k ? k.prototype : void 0, re = ne ? ne.valueOf : void 0;
function ie(e) {
var t = -1, n = e ? e.length : 0;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
function oe(e) {
var t = -1, n = e ? e.length : 0;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
function se(e) {
var t = -1, n = e ? e.length : 0;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
function ae(e) {
this.__data__ = new oe(e);
}
function ue(e, t) {
var n = Se(e) || function(e) {
return function(e) {
return function(e) {
return !!e && "object" == typeof e;
}(e) && Ae(e);
}(e) && D.call(e, "callee") && (!$.call(e, "callee") || C.call(e) == r);
}(e) ? function(e, t) {
for (var n = -1, r = Array(e); ++n < e; ) r[n] = t(n);
return r;
}(e.length, String) : [], i = n.length, o = !!i;
for (var s in e) !t && !D.call(e, s) || o && ("length" == s || me(s, i)) || n.push(s);
return n;
}
function ce(e, t, n) {
var r = e[t];
D.call(e, t) && Ee(r, n) && (void 0 !== n || t in e) || (e[t] = n);
}
function fe(e, t) {
for (var n = e.length; n--; ) if (Ee(e[n][0], t)) return n;
return -1;
}
function le(e, t, n, c, f, h, p) {
var d;
if (c && (d = h ? c(e, f, h, p) : c(e)), void 0 !== d) return d;
if (!Te(e)) return e;
var y = Se(e);
if (y) {
if (d = function(e) {
var t = e.length, n = e.constructor(t);
t && "string" == typeof e[0] && D.call(e, "index") && (n.index = e.index, n.input = e.input);
return n;
}(e), !t) return function(e, t) {
var n = -1, r = e.length;
t || (t = Array(r));
for (;++n < r; ) t[n] = e[n];
return t;
}(e, d);
} else {
var _ = ve(e), g = _ == i || _ == o;
if (Oe(e)) return function(e, t) {
if (t) return e.slice();
var n = new e.constructor(e.length);
return e.copy(n), n;
}(e, t);
if ("[object Object]" == _ || _ == r || g && !h) {
if (w(e)) return h ? e : {};
if (d = function(e) {
return "function" != typeof e.constructor || be(e) ? {} : Te(t = M(e)) ? j(t) : {};
var t;
}(g ? {} : e), !t) return function(e, t) {
return de(e, ge(e), t);
}(e, function(e, t) {
return e && de(t, Ne(t), e);
}(d, e));
} else {
if (!l[_]) return h ? e : {};
d = function(e, t, n, r) {
var i, o = e.constructor;
switch (t) {
case "[object ArrayBuffer]":
return pe(e);

case "[object Boolean]":
case "[object Date]":
return new o(+e);

case "[object DataView]":
return function(e) {
var t = r ? pe(e.buffer) : e.buffer;
return new e.constructor(t, e.byteOffset, e.byteLength);
}(e);

case "[object Float32Array]":
case "[object Float64Array]":
case "[object Int8Array]":
case "[object Int16Array]":
case "[object Int32Array]":
case "[object Uint8Array]":
case "[object Uint8ClampedArray]":
case "[object Uint16Array]":
case "[object Uint32Array]":
return function(e) {
var t = r ? pe(e.buffer) : e.buffer;
return new e.constructor(t, e.byteOffset, e.length);
}(e);

case s:
return function(e, t, n) {
return b(r ? n(E(e), !0) : E(e), v, new e.constructor());
}(e, 0, n);

case "[object Number]":
case "[object String]":
return new o(e);

case "[object RegExp]":
return function(e) {
var t = new e.constructor(e.source, u.exec(e));
return t.lastIndex = e.lastIndex, t;
}(e);

case a:
return function(e, t, n) {
return b(r ? n(A(e), !0) : A(e), m, new e.constructor());
}(e, 0, n);

case "[object Symbol]":
return i = e, re ? Object(re.call(i)) : {};
}
}(e, _, le, t);
}
}
p || (p = new ae());
var S = p.get(e);
if (S) return S;
if (p.set(e, d), !y) var O = n ? function(e) {
return function(e, t, n) {
var r = Ne(e);
return Se(e) ? r : function(e, t) {
for (var n = -1, r = t.length, i = e.length; ++n < r; ) e[i + n] = t[n];
return e;
}(r, n(e));
}(e, 0, ge);
}(e) : Ne(e);
return function(e, t) {
for (var n = -1, r = e ? e.length : 0; ++n < r && !1 !== t(e[n], n); ) ;
}(O || e, function(r, i) {
O && (r = e[i = r]), ce(d, i, le(r, t, n, c, i, e, p));
}), d;
}
function he(e) {
return !(!Te(e) || (t = e, P && P in t)) && (Ie(e) || w(e) ? L : c).test(we(e));
var t;
}
function pe(e) {
var t = new e.constructor(e.byteLength);
return new U(t).set(new U(e)), t;
}
function de(e, t, n, r) {
n || (n = {});
for (var i = -1, o = t.length; ++i < o; ) {
var s = t[i], a = r ? r(n[s], e[s], s, n, e) : void 0;
ce(n, s, void 0 === a ? e[s] : a);
}
return n;
}
function ye(e, t) {
var n, r, i = e.__data__;
return ("string" == (r = typeof (n = t)) || "number" == r || "symbol" == r || "boolean" == r ? "__proto__" !== n : null === n) ? i["string" == typeof t ? "string" : "hash"] : i.map;
}
function _e(e, t) {
var n = function(e, t) {
return null == e ? void 0 : e[t];
}(e, t);
return he(n) ? n : void 0;
}
ie.prototype.clear = function() {
this.__data__ = V ? V(null) : {};
}, ie.prototype.delete = function(e) {
return this.has(e) && delete this.__data__[e];
}, ie.prototype.get = function(e) {
var t = this.__data__;
if (V) {
var n = t[e];
return "__lodash_hash_undefined__" === n ? void 0 : n;
}
return D.call(t, e) ? t[e] : void 0;
}, ie.prototype.has = function(e) {
var t = this.__data__;
return V ? void 0 !== t[e] : D.call(t, e);
}, ie.prototype.set = function(e, t) {
return this.__data__[e] = V && void 0 === t ? "__lodash_hash_undefined__" : t, this;
}, oe.prototype.clear = function() {
this.__data__ = [];
}, oe.prototype.delete = function(e) {
var t = this.__data__, n = fe(t, e);
return !(n < 0 || (n == t.length - 1 ? t.pop() : q.call(t, n, 1), 0));
}, oe.prototype.get = function(e) {
var t = this.__data__, n = fe(t, e);
return n < 0 ? void 0 : t[n][1];
}, oe.prototype.has = function(e) {
return fe(this.__data__, e) > -1;
}, oe.prototype.set = function(e, t) {
var n = this.__data__, r = fe(n, e);
return r < 0 ? n.push([ e, t ]) : n[r][1] = t, this;
}, se.prototype.clear = function() {
this.__data__ = {
hash: new ie(),
map: new (G || oe)(),
string: new ie()
};
}, se.prototype.delete = function(e) {
return ye(this, e).delete(e);
}, se.prototype.get = function(e) {
return ye(this, e).get(e);
}, se.prototype.has = function(e) {
return ye(this, e).has(e);
}, se.prototype.set = function(e, t) {
return ye(this, e).set(e, t), this;
}, ae.prototype.clear = function() {
this.__data__ = new oe();
}, ae.prototype.delete = function(e) {
return this.__data__.delete(e);
}, ae.prototype.get = function(e) {
return this.__data__.get(e);
}, ae.prototype.has = function(e) {
return this.__data__.has(e);
}, ae.prototype.set = function(e, t) {
var n = this.__data__;
if (n instanceof oe) {
var r = n.__data__;
if (!G || r.length < 199) return r.push([ e, t ]), this;
n = this.__data__ = new se(r);
}
return n.set(e, t), this;
};
var ge = F ? S(F, Object) : function() {
return [];
}, ve = function(e) {
return C.call(e);
};
function me(e, t) {
return !!(t = null == t ? 9007199254740991 : t) && ("number" == typeof e || f.test(e)) && e > -1 && e % 1 == 0 && e < t;
}
function be(e) {
var t = e && e.constructor;
return e === ("function" == typeof t && t.prototype || N);
}
function we(e) {
if (null != e) {
try {
return B.call(e);
} catch (e) {}
try {
return e + "";
} catch (e) {}
}
return "";
}
function Ee(e, t) {
return e === t || e != e && t != t;
}
(K && "[object DataView]" != ve(new K(new ArrayBuffer(1))) || G && ve(new G()) != s || Y && "[object Promise]" != ve(Y.resolve()) || H && ve(new H()) != a || J && "[object WeakMap]" != ve(new J())) && (ve = function(e) {
var t = C.call(e), n = "[object Object]" == t ? e.constructor : void 0, r = n ? we(n) : void 0;
if (r) switch (r) {
case X:
return "[object DataView]";

case Q:
return s;

case Z:
return "[object Promise]";

case ee:
return a;

case te:
return "[object WeakMap]";
}
return t;
});
var Se = Array.isArray;
function Ae(e) {
return null != e && function(e) {
return "number" == typeof e && e > -1 && e % 1 == 0 && e <= 9007199254740991;
}(e.length) && !Ie(e);
}
var Oe = W || function() {
return !1;
};
function Ie(e) {
var t = Te(e) ? C.call(e) : "";
return t == i || t == o;
}
function Te(e) {
var t = typeof e;
return !!e && ("object" == t || "function" == t);
}
function Ne(e) {
return Ae(e) ? ue(e) : function(e) {
if (!be(e)) return z(e);
var t = [];
for (var n in Object(e)) D.call(e, n) && "constructor" != n && t.push(n);
return t;
}(e);
}
n.exports = function(e) {
return le(e, !0, !0);
};
}).call(this, n(8), n(32)(e));
}, function(e, t, n) {
n(16), e.exports = n(17);
}, function(e) {
var t = function(e) {
"use strict";
var t = Object.prototype, n = t.hasOwnProperty, r = "function" == typeof Symbol ? Symbol : {}, i = r.iterator || "@@iterator", o = r.asyncIterator || "@@asyncIterator", s = r.toStringTag || "@@toStringTag";
function a(e, t, n, r) {
var i = t && t.prototype instanceof f ? t : f, o = Object.create(i.prototype), s = new E(r || []);
return o._invoke = function(e, t, n) {
var r = "suspendedStart";
return function(i, o) {
if ("executing" === r) throw new Error("Generator is already running");
if ("completed" === r) {
if ("throw" === i) throw o;
return {
value: void 0,
done: !0
};
}
for (n.method = i, n.arg = o; ;) {
var s = n.delegate;
if (s) {
var a = m(s, n);
if (a) {
if (a === c) continue;
return a;
}
}
if ("next" === n.method) n.sent = n._sent = n.arg; else if ("throw" === n.method) {
if ("suspendedStart" === r) throw r = "completed", n.arg;
n.dispatchException(n.arg);
} else "return" === n.method && n.abrupt("return", n.arg);
r = "executing";
var f = u(e, t, n);
if ("normal" === f.type) {
if (r = n.done ? "completed" : "suspendedYield", f.arg === c) continue;
return {
value: f.arg,
done: n.done
};
}
"throw" === f.type && (r = "completed", n.method = "throw", n.arg = f.arg);
}
};
}(e, n, s), o;
}
function u(e, t, n) {
try {
return {
type: "normal",
arg: e.call(t, n)
};
} catch (e) {
return {
type: "throw",
arg: e
};
}
}
e.wrap = a;
var c = {};
function f() {}
function l() {}
function h() {}
var p = {};
p[i] = function() {
return this;
};
var d = Object.getPrototypeOf, y = d && d(d(S([])));
y && y !== t && n.call(y, i) && (p = y);
var _ = h.prototype = f.prototype = Object.create(p);
function g(e) {
[ "next", "throw", "return" ].forEach(function(t) {
e[t] = function(e) {
return this._invoke(t, e);
};
});
}
function v(e, t) {
var r;
this._invoke = function(i, o) {
function s() {
return new t(function(r, s) {
!function r(i, o, s, a) {
var c = u(e[i], e, o);
if ("throw" !== c.type) {
var f = c.arg, l = f.value;
return l && "object" == typeof l && n.call(l, "__await") ? t.resolve(l.__await).then(function(e) {
r("next", e, s, a);
}, function(e) {
r("throw", e, s, a);
}) : t.resolve(l).then(function(e) {
f.value = e, s(f);
}, function(e) {
return r("throw", e, s, a);
});
}
a(c.arg);
}(i, o, r, s);
});
}
return r = r ? r.then(s, s) : s();
};
}
function m(e, t) {
var n = e.iterator[t.method];
if (void 0 === n) {
if (t.delegate = null, "throw" === t.method) {
if (e.iterator.return && (t.method = "return", t.arg = void 0, m(e, t), "throw" === t.method)) return c;
t.method = "throw", t.arg = new TypeError("The iterator does not provide a 'throw' method");
}
return c;
}
var r = u(n, e.iterator, t.arg);
if ("throw" === r.type) return t.method = "throw", t.arg = r.arg, t.delegate = null, 
c;
var i = r.arg;
return i ? i.done ? (t[e.resultName] = i.value, t.next = e.nextLoc, "return" !== t.method && (t.method = "next", 
t.arg = void 0), t.delegate = null, c) : i : (t.method = "throw", t.arg = new TypeError("iterator result is not an object"), 
t.delegate = null, c);
}
function b(e) {
var t = {
tryLoc: e[0]
};
1 in e && (t.catchLoc = e[1]), 2 in e && (t.finallyLoc = e[2], t.afterLoc = e[3]), 
this.tryEntries.push(t);
}
function w(e) {
var t = e.completion || {};
t.type = "normal", delete t.arg, e.completion = t;
}
function E(e) {
this.tryEntries = [ {
tryLoc: "root"
} ], e.forEach(b, this), this.reset(!0);
}
function S(e) {
if (e) {
var t = e[i];
if (t) return t.call(e);
if ("function" == typeof e.next) return e;
if (!isNaN(e.length)) {
var r = -1, o = function t() {
for (;++r < e.length; ) if (n.call(e, r)) return t.value = e[r], t.done = !1, t;
return t.value = void 0, t.done = !0, t;
};
return o.next = o;
}
}
return {
next: A
};
}
function A() {
return {
value: void 0,
done: !0
};
}
return l.prototype = _.constructor = h, h.constructor = l, h[s] = l.displayName = "GeneratorFunction", 
e.isGeneratorFunction = function(e) {
var t = "function" == typeof e && e.constructor;
return !!t && (t === l || "GeneratorFunction" === (t.displayName || t.name));
}, e.mark = function(e) {
return Object.setPrototypeOf ? Object.setPrototypeOf(e, h) : (e.__proto__ = h, s in e || (e[s] = "GeneratorFunction")), 
e.prototype = Object.create(_), e;
}, e.awrap = function(e) {
return {
__await: e
};
}, g(v.prototype), v.prototype[o] = function() {
return this;
}, e.AsyncIterator = v, e.async = function(t, n, r, i, o) {
void 0 === o && (o = Promise);
var s = new v(a(t, n, r, i), o);
return e.isGeneratorFunction(n) ? s : s.next().then(function(e) {
return e.done ? e.value : s.next();
});
}, g(_), _[s] = "Generator", _[i] = function() {
return this;
}, _.toString = function() {
return "[object Generator]";
}, e.keys = function(e) {
var t = [];
for (var n in e) t.push(n);
return t.reverse(), function n() {
for (;t.length; ) {
var r = t.pop();
if (r in e) return n.value = r, n.done = !1, n;
}
return n.done = !0, n;
};
}, e.values = S, E.prototype = {
constructor: E,
reset: function(e) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = !1, 
this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(w), 
!e) for (var t in this) "t" === t.charAt(0) && n.call(this, t) && !isNaN(+t.slice(1)) && (this[t] = void 0);
},
stop: function() {
this.done = !0;
var e = this.tryEntries[0].completion;
if ("throw" === e.type) throw e.arg;
return this.rval;
},
dispatchException: function(e) {
if (this.done) throw e;
var t = this;
function r(n, r) {
return s.type = "throw", s.arg = e, t.next = n, r && (t.method = "next", t.arg = void 0), 
!!r;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var o = this.tryEntries[i], s = o.completion;
if ("root" === o.tryLoc) return r("end");
if (o.tryLoc <= this.prev) {
var a = n.call(o, "catchLoc"), u = n.call(o, "finallyLoc");
if (a && u) {
if (this.prev < o.catchLoc) return r(o.catchLoc, !0);
if (this.prev < o.finallyLoc) return r(o.finallyLoc);
} else if (a) {
if (this.prev < o.catchLoc) return r(o.catchLoc, !0);
} else {
if (!u) throw new Error("try statement without catch or finally");
if (this.prev < o.finallyLoc) return r(o.finallyLoc);
}
}
}
},
abrupt: function(e, t) {
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
var i = this.tryEntries[r];
if (i.tryLoc <= this.prev && n.call(i, "finallyLoc") && this.prev < i.finallyLoc) {
var o = i;
break;
}
}
o && ("break" === e || "continue" === e) && o.tryLoc <= t && t <= o.finallyLoc && (o = null);
var s = o ? o.completion : {};
return s.type = e, s.arg = t, o ? (this.method = "next", this.next = o.finallyLoc, 
c) : this.complete(s);
},
complete: function(e, t) {
if ("throw" === e.type) throw e.arg;
return "break" === e.type || "continue" === e.type ? this.next = e.arg : "return" === e.type ? (this.rval = this.arg = e.arg, 
this.method = "return", this.next = "end") : "normal" === e.type && t && (this.next = t), 
c;
},
finish: function(e) {
for (var t = this.tryEntries.length - 1; t >= 0; --t) {
var n = this.tryEntries[t];
if (n.finallyLoc === e) return this.complete(n.completion, n.afterLoc), w(n), c;
}
},
catch: function(e) {
for (var t = this.tryEntries.length - 1; t >= 0; --t) {
var n = this.tryEntries[t];
if (n.tryLoc === e) {
var r = n.completion;
if ("throw" === r.type) {
var i = r.arg;
w(n);
}
return i;
}
}
throw new Error("illegal catch attempt");
},
delegateYield: function(e, t, n) {
return this.delegate = {
iterator: S(e),
resultName: t,
nextLoc: n
}, "next" === this.method && (this.arg = void 0), c;
}
}, e;
}(e.exports);
try {
regeneratorRuntime = t;
} catch (e) {}
}, function(e, t, n) {
"use strict";
var r = this && this.__createBinding || (Object.create ? function(e, t, n, r) {
void 0 === r && (r = n), Object.defineProperty(e, r, {
enumerable: !0,
get: function() {
return t[n];
}
});
} : function(e, t, n, r) {
void 0 === r && (r = n), e[r] = t[n];
}), i = this && this.__setModuleDefault || (Object.create ? function(e, t) {
Object.defineProperty(e, "default", {
enumerable: !0,
value: t
});
} : function(e, t) {
e.default = t;
}), o = this && this.__importStar || function(e) {
if (e && e.__esModule) return e;
var t = {};
if (null != e) for (var n in e) "default" !== n && Object.hasOwnProperty.call(e, n) && r(t, e, n);
return i(t, e), t;
}, s = (this && this.__importDefault || function(e) {
return e && e.__esModule ? e : {
default: e
};
})(n(40)), a = n(39), u = n(30), c = n(31), f = n(38), l = n(37), h = o(n(36)).version;
s.default.registerVersion(h);
try {
a.registerAuth(s.default), u.registerFunctions(s.default), c.registerStorage(s.default), 
l.registerDatabase(s.default), f.registerRealtime(s.default);
} catch (e) {}
try {
window.cloudbase = s.default;
} catch (e) {}
t.default = s.default, e.exports = s.default;
}, function(e, t) {
"use strict";
Object.defineProperty(t, "__esModule", {
value: !0
}), t.ERRORS = void 0, t.ERRORS = {
INVALID_PARAMS: "INVALID_PARAMS",
INVALID_SYNTAX: "INVALID_SYNTAX",
INVALID_OPERATION: "INVALID_OPERATION",
OPERATION_FAIL: "OPERATION_FAIL",
NETWORK_ERROR: "NETWORK_ERROR",
UNKOWN_ERROR: "UNKOWN_ERROR"
};
}, function(e, t, n) {
"use strict";
var r = this && this.__createBinding || (Object.create ? function(e, t, n, r) {
void 0 === r && (r = n), Object.defineProperty(e, r, {
enumerable: !0,
get: function() {
return t[n];
}
});
} : function(e, t, n, r) {
void 0 === r && (r = n), e[r] = t[n];
}), i = this && this.__setModuleDefault || (Object.create ? function(e, t) {
Object.defineProperty(e, "default", {
enumerable: !0,
value: t
});
} : function(e, t) {
e.default = t;
}), o = this && this.__importStar || function(e) {
if (e && e.__esModule) return e;
var t = {};
if (null != e) for (var n in e) "default" !== n && Object.hasOwnProperty.call(e, n) && r(t, e, n);
return i(t, e), t;
};
Object.defineProperty(t, "__esModule", {
value: !0
}), t.useDefaultAdapter = t.useAdapters = t.RUNTIME = void 0;
var s, a = o(n(20)), u = n(5);
!function(e) {
e.WEB = "web", e.WX_MP = "wx_mp";
}(s = t.RUNTIME || (t.RUNTIME = {})), t.useAdapters = function(e) {
for (var t = 0, n = u.isArray(e) ? e : [ e ]; t < n.length; t++) {
var r = n[t], i = r.isMatch, o = r.genAdapter, s = r.runtime;
if (i()) return {
adapter: o(),
runtime: s
};
}
}, t.useDefaultAdapter = function() {
return {
adapter: a.genAdapter(),
runtime: s.WEB
};
};
}, function(e, t, n) {
"use strict";
var r, i = this && this.__extends || (r = function(e, t) {
return (r = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
})(e, t);
}, function(e, t) {
function n() {
this.constructor = e;
}
r(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
new n());
}), o = this && this.__assign || function() {
return (o = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}).apply(this, arguments);
}, s = this && this.__awaiter || function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, a = this && this.__generator || function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
};
Object.defineProperty(t, "__esModule", {
value: !0
}), t.WebRequest = t.genAdapter = void 0;
var u = n(4), c = n(5), f = n(10), l = function(e) {
function t(t) {
var n = e.call(this) || this, r = t.timeout, i = t.timeoutMsg, o = t.restrictedMethods;
return n._timeout = r || 0, n._timeoutMsg = i || "请求超时", n._restrictedMethods = o || [ "get", "post", "upload", "download" ], 
n;
}
return i(t, e), t.prototype.get = function(e) {
return this._request(o(o({}, e), {
method: "get"
}), this._restrictedMethods.includes("get"));
}, t.prototype.post = function(e) {
return this._request(o(o({}, e), {
method: "post"
}), this._restrictedMethods.includes("post"));
}, t.prototype.put = function(e) {
return this._request(o(o({}, e), {
method: "put"
}));
}, t.prototype.upload = function(e) {
var t = e.data, n = e.file, r = e.name, i = new FormData();
for (var s in t) i.append(s, t[s]);
return i.append("key", r), i.append("file", n), this._request(o(o({}, e), {
data: i,
method: "post"
}), this._restrictedMethods.includes("upload"));
}, t.prototype.download = function(e) {
return s(this, void 0, void 0, function() {
var t, n, r, i;
return a(this, function(s) {
switch (s.label) {
case 0:
return s.trys.push([ 0, 2, , 3 ]), [ 4, this.get(o(o({}, e), {
headers: {},
responseType: "blob"
})) ];

case 1:
return t = s.sent().data, n = window.URL.createObjectURL(new Blob([ t ])), r = decodeURIComponent(new URL(e.url).pathname.split("/").pop() || ""), 
(i = document.createElement("a")).href = n, i.setAttribute("download", r), i.style.display = "none", 
document.body.appendChild(i), i.click(), window.URL.revokeObjectURL(n), document.body.removeChild(i), 
[ 3, 3 ];

case 2:
return s.sent(), [ 3, 3 ];

case 3:
return [ 2, new Promise(function(t) {
t({
statusCode: 200,
tempFilePath: e.url
});
}) ];
}
});
});
}, t.prototype._request = function(e, t) {
var n = this;
void 0 === t && (t = !1);
var r = String(e.method).toLowerCase() || "get";
return new Promise(function(i) {
var o, s, a = e.url, u = e.headers, l = void 0 === u ? {} : u, h = e.data, p = e.responseType, d = e.withCredentials, y = e.body, _ = e.onUploadProgress, g = c.formatUrl(f.getProtocol(), a, "get" === r ? h : {}), v = new XMLHttpRequest();
for (var m in v.open(r, g), p && (v.responseType = p), l) v.setRequestHeader(m, l[m]);
_ && v.addEventListener("progress", _), v.onreadystatechange = function() {
var e = {};
if (4 === v.readyState) {
var t = v.getAllResponseHeaders().trim().split(/[\r\n]+/), n = {};
t.forEach(function(e) {
var t = e.split(": "), r = t.shift().toLowerCase(), i = t.join(": ");
n[r] = i;
}), e.header = n, e.statusCode = v.status;
try {
e.data = "blob" === p ? v.response : JSON.parse(v.responseText);
} catch (t) {
e.data = "blob" === p ? v.response : v.responseText;
}
clearTimeout(o), i(e);
}
}, t && n._timeout && (o = setTimeout(function() {
console.warn(n._timeoutMsg), v.abort();
}, n._timeout)), s = c.isFormData(h) ? h : "application/x-www-form-urlencoded" === l["content-type"] ? c.toQueryString(h) : y || (h ? JSON.stringify(h) : void 0), 
d && (v.withCredentials = !0), v.send(s);
});
}, t;
}(u.AbstractSDKRequest);
t.WebRequest = l, t.genAdapter = function() {
return {
root: window,
reqClass: l,
wsClass: WebSocket,
localStorage: localStorage,
sessionStorage: sessionStorage
};
};
}, function(e, t, n) {
var r;
e.exports = (r = n(7), n(22), n(23), r.HmacSHA256);
}, function(e, t, n) {
var r;
e.exports = (r = n(7), function(e) {
var t = r, n = t.lib, i = n.WordArray, o = n.Hasher, s = t.algo, a = [], u = [];
!function() {
function t(t) {
for (var n = e.sqrt(t), r = 2; r <= n; r++) if (!(t % r)) return !1;
return !0;
}
function n(e) {
return 4294967296 * (e - (0 | e)) | 0;
}
for (var r = 2, i = 0; i < 64; ) t(r) && (i < 8 && (a[i] = n(e.pow(r, .5))), u[i] = n(e.pow(r, 1 / 3)), 
i++), r++;
}();
var c = [], f = s.SHA256 = o.extend({
_doReset: function() {
this._hash = new i.init(a.slice(0));
},
_doProcessBlock: function(e, t) {
for (var n = this._hash.words, r = n[0], i = n[1], o = n[2], s = n[3], a = n[4], f = n[5], l = n[6], h = n[7], p = 0; p < 64; p++) {
if (p < 16) c[p] = 0 | e[t + p]; else {
var d = c[p - 15], y = (d << 25 | d >>> 7) ^ (d << 14 | d >>> 18) ^ d >>> 3, _ = c[p - 2], g = (_ << 15 | _ >>> 17) ^ (_ << 13 | _ >>> 19) ^ _ >>> 10;
c[p] = y + c[p - 7] + g + c[p - 16];
}
var v = r & i ^ r & o ^ i & o, m = (r << 30 | r >>> 2) ^ (r << 19 | r >>> 13) ^ (r << 10 | r >>> 22), b = h + ((a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25)) + (a & f ^ ~a & l) + u[p] + c[p];
h = l, l = f, f = a, a = s + b | 0, s = o, o = i, i = r, r = b + (m + v) | 0;
}
n[0] = n[0] + r | 0, n[1] = n[1] + i | 0, n[2] = n[2] + o | 0, n[3] = n[3] + s | 0, 
n[4] = n[4] + a | 0, n[5] = n[5] + f | 0, n[6] = n[6] + l | 0, n[7] = n[7] + h | 0;
},
_doFinalize: function() {
var t = this._data, n = t.words, r = 8 * this._nDataBytes, i = 8 * t.sigBytes;
return n[i >>> 5] |= 128 << 24 - i % 32, n[14 + (i + 64 >>> 9 << 4)] = e.floor(r / 4294967296), 
n[15 + (i + 64 >>> 9 << 4)] = r, t.sigBytes = 4 * n.length, this._process(), this._hash;
},
clone: function() {
var e = o.clone.call(this);
return e._hash = this._hash.clone(), e;
}
});
t.SHA256 = o._createHelper(f), t.HmacSHA256 = o._createHmacHelper(f);
}(Math), r.SHA256);
}, function(e, t, n) {
var r, i, o;
e.exports = (i = (r = n(7)).lib.Base, o = r.enc.Utf8, void (r.algo.HMAC = i.extend({
init: function(e, t) {
e = this._hasher = new e.init(), "string" == typeof t && (t = o.parse(t));
var n = e.blockSize, r = 4 * n;
t.sigBytes > r && (t = e.finalize(t)), t.clamp();
for (var i = this._oKey = t.clone(), s = this._iKey = t.clone(), a = i.words, u = s.words, c = 0; c < n; c++) a[c] ^= 1549556828, 
u[c] ^= 909522486;
i.sigBytes = s.sigBytes = r, this.reset();
},
reset: function() {
var e = this._hasher;
e.reset(), e.update(this._iKey);
},
update: function(e) {
return this._hasher.update(e), this;
},
finalize: function(e) {
var t = this._hasher, n = t.finalize(e);
return t.reset(), t.finalize(this._oKey.clone().concat(n));
}
})));
}, function(e, t, n) {
var r, i, o;
e.exports = (o = n(7), i = (r = o).lib.WordArray, r.enc.Base64 = {
stringify: function(e) {
var t = e.words, n = e.sigBytes, r = this._map;
e.clamp();
for (var i = [], o = 0; o < n; o += 3) for (var s = (t[o >>> 2] >>> 24 - o % 4 * 8 & 255) << 16 | (t[o + 1 >>> 2] >>> 24 - (o + 1) % 4 * 8 & 255) << 8 | t[o + 2 >>> 2] >>> 24 - (o + 2) % 4 * 8 & 255, a = 0; a < 4 && o + .75 * a < n; a++) i.push(r.charAt(s >>> 6 * (3 - a) & 63));
var u = r.charAt(64);
if (u) for (;i.length % 4; ) i.push(u);
return i.join("");
},
parse: function(e) {
var t = e.length, n = this._map, r = this._reverseMap;
if (!r) {
r = this._reverseMap = [];
for (var o = 0; o < n.length; o++) r[n.charCodeAt(o)] = o;
}
var s = n.charAt(64);
if (s) {
var a = e.indexOf(s);
-1 !== a && (t = a);
}
return function(e, t, n) {
for (var r = [], o = 0, s = 0; s < t; s++) if (s % 4) {
var a = n[e.charCodeAt(s - 1)] << s % 4 * 2, u = n[e.charCodeAt(s)] >>> 6 - s % 4 * 2;
r[o >>> 2] |= (a | u) << 24 - o % 4 * 8, o++;
}
return i.create(r, o);
}(e, t, r);
},
_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
}, o.enc.Base64);
}, function(e, t, n) {
e.exports = n(7).enc.Utf8;
}, function(e, t, n) {
"use strict";
(function(e) {
var r, i = this && this.__extends || (r = function(e, t) {
return (r = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
})(e, t);
}, function(e, t) {
function n() {
this.constructor = e;
}
r(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
new n());
}), o = this && this.__awaiter || function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, s = this && this.__generator || function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
};
Object.defineProperty(t, "__esModule", {
value: !0
}), t.CloudbaseCache = void 0;
var a = n(4), u = n(5), c = n(9), f = function(e) {
function t(t) {
var n = e.call(this) || this;
return n._root = t, t.tcbCacheObject || (t.tcbCacheObject = {}), n;
}
return i(t, e), t.prototype.setItem = function(e, t) {
this._root.tcbCacheObject[e] = t;
}, t.prototype.getItem = function(e) {
return this._root.tcbCacheObject[e];
}, t.prototype.removeItem = function(e) {
delete this._root.tcbCacheObject[e];
}, t.prototype.clear = function() {
delete this._root.tcbCacheObject;
}, t;
}(a.AbstractStorage);
function l(e, t) {
switch (e) {
case "local":
return t.localStorage ? t.localStorage : (u.printWarn(c.ERRORS.INVALID_PARAMS, "localStorage is not supported on current platform"), 
new f(t.root));

case "none":
return new f(t.root);

default:
return t.sessionStorage ? t.sessionStorage : (u.printWarn(c.ERRORS.INVALID_PARAMS, "sessionStorage is not supported on current platform"), 
new f(t.root));
}
}
var h = function() {
function t(e) {
this.keys = {};
var t = e.persistence, n = e.platformInfo, r = void 0 === n ? {} : n, i = e.keys, o = void 0 === i ? {} : i, s = e.alwaysLocalKeys, a = void 0 === s ? [] : s;
this._platformInfo = r, this._alwaysLocalKeys = a, this._storage || (this._persistence = r.adapter.primaryStorage || t, 
this._storage = l(this._persistence, r.adapter), this.keys = o);
}
return Object.defineProperty(t.prototype, "mode", {
get: function() {
return this._storage.mode || "sync";
},
enumerable: !1,
configurable: !0
}), Object.defineProperty(t.prototype, "persistence", {
get: function() {
return this._persistence;
},
enumerable: !1,
configurable: !0
}), t.prototype.updatePersistence = function(e) {
if ("async" !== this.mode) {
if (e !== this._persistence) {
var t = "local" === this._persistence;
this._persistence = e;
var n = l(e, this._platformInfo.adapter);
for (var r in this.keys) {
var i = this.keys[r];
if (!t || !this._alwaysLocalKeys.includes(r)) {
var o = this._storage.getItem(i);
u.isUndefined(o) || u.isNull(o) || (n.setItem(i, o), this._storage.removeItem(i));
}
}
this._storage = n;
}
} else u.printWarn(c.ERRORS.INVALID_OPERATION, "current platform's storage is asynchronous, please use updatePersistenceAsync insteed");
}, t.prototype.updatePersistenceAsync = function(e) {
return o(this, void 0, void 0, function() {
var t, n, r, i, o, a, c, f;
return s(this, function(s) {
switch (s.label) {
case 0:
if (e === this._persistence) return [ 2 ];
for (i in t = "local" === this._persistence, this._persistence = e, n = l(e, this._platformInfo.adapter), 
r = [], this.keys) r.push(i);
o = 0, s.label = 1;

case 1:
return o < r.length ? (a = r[o], c = this.keys[a], t && this._alwaysLocalKeys.includes(a) ? [ 3, 4 ] : [ 4, this._storage.getItem(c) ]) : [ 3, 5 ];

case 2:
return f = s.sent(), u.isUndefined(f) || u.isNull(f) ? [ 3, 4 ] : (n.setItem(c, f), 
[ 4, this._storage.removeItem(c) ]);

case 3:
s.sent(), s.label = 4;

case 4:
return o++, [ 3, 1 ];

case 5:
return this._storage = n, [ 2 ];
}
});
});
}, t.prototype.setStore = function(e, t, n) {
if ("async" !== this.mode) {
if (this._storage) try {
var r = {
version: n || "localCachev1",
content: t
};
this._storage.setItem(e, JSON.stringify(r));
} catch (e) {
throw new Error(JSON.stringify({
code: c.ERRORS.OPERATION_FAIL,
msg: "[" + c.getSdkName() + "][" + c.ERRORS.OPERATION_FAIL + "]setStore failed",
info: e
}));
}
} else u.printWarn(c.ERRORS.INVALID_OPERATION, "current platform's storage is asynchronous, please use setStoreAsync insteed");
}, t.prototype.setStoreAsync = function(e, t, n) {
return o(this, void 0, void 0, function() {
var r;
return s(this, function(i) {
switch (i.label) {
case 0:
if (!this._storage) return [ 2 ];
i.label = 1;

case 1:
return i.trys.push([ 1, 3, , 4 ]), r = {
version: n || "localCachev1",
content: t
}, [ 4, this._storage.setItem(e, JSON.stringify(r)) ];

case 2:
return i.sent(), [ 3, 4 ];

case 3:
return i.sent(), [ 2 ];

case 4:
return [ 2 ];
}
});
});
}, t.prototype.getStore = function(t, n) {
var r;
if ("async" !== this.mode) {
try {
if (void 0 !== e && (null === (r = e.env) || void 0 === r ? void 0 : r.tcb_token)) return e.env.tcb_token;
if (!this._storage) return "";
} catch (e) {
return "";
}
n = n || "localCachev1";
var i = this._storage.getItem(t);
return i && i.indexOf(n) >= 0 ? JSON.parse(i).content : "";
}
u.printWarn(c.ERRORS.INVALID_OPERATION, "current platform's storage is asynchronous, please use getStoreAsync insteed");
}, t.prototype.getStoreAsync = function(t, n) {
var r;
return o(this, void 0, void 0, function() {
var i;
return s(this, function(o) {
switch (o.label) {
case 0:
try {
if (void 0 !== e && (null === (r = e.env) || void 0 === r ? void 0 : r.tcb_token)) return [ 2, e.env.tcb_token ];
if (!this._storage) return [ 2, "" ];
} catch (e) {
return [ 2, "" ];
}
return n = n || "localCachev1", [ 4, this._storage.getItem(t) ];

case 1:
return (i = o.sent()) && i.indexOf(n) >= 0 ? [ 2, JSON.parse(i).content ] : [ 2, "" ];
}
});
});
}, t.prototype.removeStore = function(e) {
"async" !== this.mode ? this._storage.removeItem(e) : u.printWarn(c.ERRORS.INVALID_OPERATION, "current platform's storage is asynchronous, please use removeStoreAsync insteed");
}, t.prototype.removeStoreAsync = function(e) {
return o(this, void 0, void 0, function() {
return s(this, function(t) {
switch (t.label) {
case 0:
return [ 4, this._storage.removeItem(e) ];

case 1:
return t.sent(), [ 2 ];
}
});
});
}, t;
}();
t.CloudbaseCache = h;
}).call(this, n(11));
}, function(e, t, n) {
"use strict";
var r, i = this && this.__extends || (r = function(e, t) {
return (r = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
})(e, t);
}, function(e, t) {
function n() {
this.constructor = e;
}
r(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
new n());
}), o = this && this.__spreadArrays || function() {
for (var e = 0, t = 0, n = arguments.length; t < n; t++) e += arguments[t].length;
var r = Array(e), i = 0;
for (t = 0; t < n; t++) for (var o = arguments[t], s = 0, a = o.length; s < a; s++, 
i++) r[i] = o[s];
return r;
};
Object.defineProperty(t, "__esModule", {
value: !0
}), t.removeEventListener = t.activateEvent = t.addEventListener = t.CloudbaseEventEmitter = t.IErrorEvent = t.CloudbaseEvent = void 0;
var s = n(5), a = function(e, t) {
this.data = t || null, this.name = e;
};
t.CloudbaseEvent = a;
var u = function(e) {
function t(t, n) {
var r = e.call(this, "error", {
error: t,
data: n
}) || this;
return r.error = t, r;
}
return i(t, e), t;
}(a);
t.IErrorEvent = u;
var c = function() {
function e() {
this._listeners = {};
}
return e.prototype.on = function(e, t) {
return function(e, t, n) {
n[e] = n[e] || [], n[e].push(t);
}(e, t, this._listeners), this;
}, e.prototype.off = function(e, t) {
return function(e, t, n) {
if (null == n ? void 0 : n[e]) {
var r = n[e].indexOf(t);
-1 !== r && n[e].splice(r, 1);
}
}(e, t, this._listeners), this;
}, e.prototype.fire = function(e, t) {
if (s.isInstanceOf(e, u)) return console.error(e.error), this;
var n = s.isString(e) ? new a(e, t || {}) : e, r = n.name;
if (this._listens(r)) {
n.target = this;
for (var i = 0, c = this._listeners[r] ? o(this._listeners[r]) : []; i < c.length; i++) c[i].call(this, n);
}
return this;
}, e.prototype._listens = function(e) {
return this._listeners[e] && this._listeners[e].length > 0;
}, e;
}();
t.CloudbaseEventEmitter = c;
var f = new c();
t.addEventListener = function(e, t) {
f.on(e, t);
}, t.activateEvent = function(e, t) {
void 0 === t && (t = {}), f.fire(e, t);
}, t.removeEventListener = function(e, t) {
f.off(e, t);
};
}, function(e, t, n) {
"use strict";
var r = this && this.__createBinding || (Object.create ? function(e, t, n, r) {
void 0 === r && (r = n), Object.defineProperty(e, r, {
enumerable: !0,
get: function() {
return t[n];
}
});
} : function(e, t, n, r) {
void 0 === r && (r = n), e[r] = t[n];
}), i = this && this.__exportStar || function(e, t) {
for (var n in e) "default" === n || t.hasOwnProperty(n) || r(t, e, n);
};
Object.defineProperty(t, "__esModule", {
value: !0
}), i(n(29), t);
}, function(e, t, n) {
"use strict";
var r = this && this.__awaiter || function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, i = this && this.__generator || function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
};
Object.defineProperty(t, "__esModule", {
value: !0
}), t.catchErrorsDecorator = void 0;
var o = n(5), s = n(9), a = !1;
"undefined" != typeof navigator && navigator.userAgent && (a = -1 !== navigator.userAgent.indexOf("Firefox"));
var u = a ? /(\.js\/)?__decorate(\$\d+)?<@.*\d$/ : /(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/, c = /https?\:\/\/.+\:\d*\/.*\.js\:\d+\:\d+/;
function f(e) {
var t = e.err, n = e.className, r = e.methodName, i = e.sourceLink;
if (!i) return null;
var o, s = t.stack.split("\n"), u = a ? /^catchErrorsDecorator\/<\/descriptor.value@.*\d$/ : new RegExp(n + "\\.descriptor.value\\s*\\[as\\s" + r + "\\]\\s*\\(.*\\)$"), f = a ? /^catchErrorsDecorator\/<\/descriptor.value/ : new RegExp(n + "\\.descriptor.value\\s*\\[as\\s" + r + "\\]"), l = s.findIndex(function(e) {
return u.test(e);
});
if (-1 !== l) {
var h = s.filter(function(e, t) {
return t > l;
});
h.unshift(s[l].replace(f, n + "." + r).replace(c, i)), (o = new Error()).stack = (a ? "@debugger" : "Error") + "\n" + h.join("\n");
}
return o;
}
t.catchErrorsDecorator = function(e) {
var t = e.mode, n = void 0 === t ? "async" : t, a = e.customInfo, l = void 0 === a ? {} : a, h = e.title, p = e.messages, d = void 0 === p ? [] : p;
return function(e, t, a) {
if (s.IS_DEBUG_MODE) {
var p = l.className || e.constructor.name, y = l.methodName || t, _ = a.value, g = function() {
var e = "", t = new Error().stack.split("\n"), n = t.findIndex(function(e) {
return u.test(e);
});
if (-1 !== n) {
var r = c.exec(t[n + 1] || "");
e = r ? r[0] : "";
}
return e;
}();
a.value = "sync" === n ? function() {
for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
var n = f({
err: new Error(),
className: p,
methodName: y,
sourceLink: g
});
try {
return _.apply(this, e);
} catch (e) {
var r = e, i = e.message, s = {
title: h || p + "." + y + " failed",
content: [ {
type: "error",
body: e
} ]
};
if (i && /^\{.*\}$/.test(i)) {
var a = JSON.parse(i);
s.subtitle = i, a.code && (r = n || e, s.content = d.map(function(e) {
return {
type: "info",
body: e
};
}));
}
throw o.printGroupLog(s), r;
}
} : function() {
for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
return r(this, void 0, void 0, function() {
var t, n, r, s, a, u;
return i(this, function(i) {
switch (i.label) {
case 0:
t = f({
err: new Error(),
className: p,
methodName: y,
sourceLink: g
}), i.label = 1;

case 1:
return i.trys.push([ 1, 3, , 4 ]), [ 4, _.apply(this, e) ];

case 2:
return [ 2, i.sent() ];

case 3:
throw n = i.sent(), r = n, s = n.message, a = {
title: h || p + "." + y + " failed",
content: [ {
type: "error",
body: n
} ]
}, s && /^\{.*\}$/.test(s) && (u = JSON.parse(s), a.subtitle = u, u.code && (r = t || n, 
a.content = d.map(function(e) {
return {
type: "info",
body: e
};
}))), o.printGroupLog(a), r;

case 4:
return [ 2 ];
}
});
});
};
}
};
};
}, function(e, t, n) {
"use strict";
n.r(t), n.d(t, "registerFunctions", function() {
return d;
});
var r = n(0), i = function(e, t, n, r) {
var i, o = arguments.length, s = o < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, n) : r;
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, n, r); else for (var a = e.length - 1; a >= 0; a--) (i = e[a]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, n, s) : i(t, n)) || s);
return o > 3 && s && Object.defineProperty(t, n, s), s;
}, o = function(e, t) {
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(e, t);
}, s = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, a = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, u = r.constants.getSdkName, c = r.constants.ERRORS, f = r.constants.COMMUNITY_SITE_URL, l = r.utils.execCallback, h = r.helpers.catchErrorsDecorator, p = {
name: "functions",
entity: {
callFunction: new (function() {
function e() {}
return e.prototype.callFunction = function(e, t) {
return s(this, void 0, void 0, function() {
var n, r, i, o, s, f, h, p, d, y, _, g;
return a(this, function(a) {
switch (a.label) {
case 0:
if (n = e.name, r = e.data, i = e.query, o = e.parse, s = e.search, !n) throw new Error(JSON.stringify({
code: c.INVALID_PARAMS,
msg: "[functions.callFunction] invalid function name"
}));
try {
f = r ? JSON.stringify(r) : "";
} catch (e) {
throw new Error(JSON.stringify({
code: c.INVALID_PARAMS,
msg: "[functions.callFunction] invalid data"
}));
}
h = "functions.invokeFunction", p = {
inQuery: i,
parse: o,
search: s,
function_name: n,
request_data: f
}, d = this.request, a.label = 1;

case 1:
return a.trys.push([ 1, 3, , 4 ]), [ 4, d.send(h, p) ];

case 2:
if ((y = a.sent()).code) return [ 2, l(t, null, y) ];
if (_ = y.data.response_data, o) return [ 2, l(t, null, {
result: _,
requestId: y.requestId
}) ];
try {
return _ = JSON.parse(y.data.response_data), [ 2, l(t, null, {
result: _,
requestId: y.requestId
}) ];
} catch (e) {
l(t, new Error("[" + u() + "][" + c.INVALID_PARAMS + "][functions.callFunction] response data must be json"));
}
return [ 3, 4 ];

case 3:
return g = a.sent(), l(t, g), [ 3, 4 ];

case 4:
return [ 2 ];
}
});
});
}, i([ h({
customInfo: {
className: "Cloudbase",
methodName: "callFunction"
},
title: "函数调用失败",
messages: [ "请确认以下各项：", "  1 - 调用 callFunction() 的语法或参数是否正确", "  2 - 当前环境下是否存在此函数", "  3 - 函数安全规则是否限制了当前登录状态访问", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + f ]
}), o("design:type", Function), o("design:paramtypes", [ Object, Function ]), o("design:returntype", Promise) ], e.prototype, "callFunction", null), 
e;
}())().callFunction
}
};
try {
cloudbase.registerComponent(p);
} catch (e) {}
function d(e) {
try {
e.registerComponent(p);
} catch (e) {
console.warn(e);
}
}
}, function(e, t, n) {
"use strict";
n.r(t), n.d(t, "registerStorage", function() {
return v;
});
var r = n(0), i = function(e, t, n, r) {
var i, o = arguments.length, s = o < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, n) : r;
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, n, r); else for (var a = e.length - 1; a >= 0; a--) (i = e[a]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, n, s) : i(t, n)) || s);
return o > 3 && s && Object.defineProperty(t, n, s), s;
}, o = function(e, t) {
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(e, t);
}, s = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, a = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, u = r.constants.getSdkName, c = r.constants.ERRORS, f = r.constants.COMMUNITY_SITE_URL, l = r.utils.isArray, h = r.utils.isString, p = r.utils.isPalinObject, d = r.utils.execCallback, y = r.helpers.catchErrorsDecorator, _ = new (function() {
function e() {}
return e.prototype.uploadFile = function(e, t) {
return s(this, void 0, void 0, function() {
var n, r, i, o, s, f, l, p, y, _, g, v, m, b;
return a(this, function(a) {
switch (a.label) {
case 0:
if (n = e.cloudPath, r = e.filePath, i = e.onUploadProgress, !h(n) || !r) throw new Error(JSON.stringify({
code: c.INVALID_PARAMS,
msg: "[storage.uploadFile] invalid params"
}));
return [ 4, (o = this.request).send("storage.getUploadMetadata", {
path: n
}) ];

case 1:
return s = a.sent(), f = s.data, l = f.url, p = f.authorization, y = f.token, _ = f.fileId, 
g = f.cosFileId, v = s.requestId, m = {
key: n,
signature: p,
"x-cos-meta-fileid": g,
success_action_status: "201",
"x-cos-security-token": y
}, [ 4, o.upload({
url: l,
data: m,
file: r,
name: n,
onUploadProgress: i
}) ];

case 2:
return 201 === (b = a.sent()).statusCode ? [ 2, d(t, null, {
fileID: _,
requestId: v
}) ] : [ 2, d(t, new Error("[" + u() + "][" + c.OPERATION_FAIL + "][storage]:" + b.data)) ];
}
});
});
}, e.prototype.getUploadMetadata = function(e, t) {
return s(this, void 0, void 0, function() {
var n, r, i, o, s;
return a(this, function(a) {
switch (a.label) {
case 0:
if (n = e.cloudPath, !h(n)) throw new Error(JSON.stringify({
code: c.INVALID_PARAMS,
msg: "[storage.getUploadMetadata] invalid cloudPath"
}));
r = this.request, i = "storage.getUploadMetadata", a.label = 1;

case 1:
return a.trys.push([ 1, 3, , 4 ]), [ 4, r.send(i, {
path: n
}) ];

case 2:
return o = a.sent(), [ 2, d(t, null, o) ];

case 3:
return s = a.sent(), [ 2, d(t, s) ];

case 4:
return [ 2 ];
}
});
});
}, e.prototype.deleteFile = function(e, t) {
return s(this, void 0, void 0, function() {
var n, r, i, o, s, u;
return a(this, function(a) {
switch (a.label) {
case 0:
if (!(n = e.fileList) || !l(n) || 0 === n.length) throw new Error(JSON.stringify({
code: c.INVALID_PARAMS,
msg: "[storage.deleteFile] fileList must not be empty"
}));
for (r = 0, i = n; r < i.length; r++) if (!(o = i[r]) || !h(o)) throw new Error(JSON.stringify({
code: c.INVALID_PARAMS,
msg: "[storage.deleteFile] fileID must be string"
}));
return [ 4, this.request.send("storage.batchDeleteFile", {
fileid_list: n
}) ];

case 1:
return (s = a.sent()).code ? [ 2, d(t, null, s) ] : (u = {
fileList: s.data.delete_list,
requestId: s.requestId
}, [ 2, d(t, null, u) ]);
}
});
});
}, e.prototype.getTempFileURL = function(e, t) {
return s(this, void 0, void 0, function() {
var n, r, i, o, s, u;
return a(this, function(a) {
switch (a.label) {
case 0:
if (!(n = e.fileList) || !l(n) || 0 === n.length) throw new Error(JSON.stringify({
code: c.INVALID_PARAMS,
msg: "[storage.getTempFileURL] fileList must not be empty"
}));
for (r = [], i = 0, o = n; i < o.length; i++) if (s = o[i], p(s)) {
if (!s.hasOwnProperty("fileID") || !s.hasOwnProperty("maxAge")) throw new Error(JSON.stringify({
code: c.INVALID_PARAMS,
msg: "[storage.getTempFileURL] file info must include fileID and maxAge"
}));
r.push({
fileid: s.fileID,
max_age: s.maxAge
});
} else {
if (!h(s)) throw new Error(JSON.stringify({
code: c.INVALID_PARAMS,
msg: "[storage.getTempFileURL] invalid fileList"
}));
r.push({
fileid: s
});
}
return [ 4, this.request.send("storage.batchGetDownloadUrl", {
file_list: r
}) ];

case 1:
return (u = a.sent()).code ? [ 2, d(t, null, u) ] : [ 2, d(t, null, {
fileList: u.data.download_list,
requestId: u.requestId
}) ];
}
});
});
}, e.prototype.downloadFile = function(e, t) {
return s(this, void 0, void 0, function() {
var n, r, i, o, s, u;
return a(this, function(a) {
switch (a.label) {
case 0:
if (n = e.fileID, !h(n)) throw new Error(JSON.stringify({
code: c.INVALID_PARAMS,
msg: "[storage.getTempFileURL] fileID must be string"
}));
return [ 4, this.getTempFileURL.call(this, {
fileList: [ {
fileID: n,
maxAge: 600
} ]
}) ];

case 1:
return r = a.sent(), "SUCCESS" !== (i = r.fileList[0]).code ? [ 2, d(t, i) ] : (o = this.request, 
s = encodeURI(i.download_url), [ 4, o.download({
url: s
}) ]);

case 2:
return u = a.sent(), [ 2, d(t, null, u) ];
}
});
});
}, i([ y({
customInfo: {
className: "Cloudbase",
methodName: "uploadFile"
},
title: "上传文件失败",
messages: [ "请确认以下各项：", "  1 - 调用 uploadFile() 的语法或参数是否正确", "  2 - 当前域名是否在安全域名列表中：https://console.cloud.tencent.com/tcb/env/safety", "  3 - 云存储安全规则是否限制了当前登录状态访问", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + f ]
}), o("design:type", Function), o("design:paramtypes", [ Object, Function ]), o("design:returntype", Promise) ], e.prototype, "uploadFile", null), 
i([ y({
customInfo: {
className: "Cloudbase",
methodName: "getUploadMetadata"
},
title: "获取上传元信息失败",
messages: [ "请确认以下各项：", "  1 - 调用 getUploadMetadata() 的语法或参数是否正确", "  2 - 当前域名是否在安全域名列表中：https://console.cloud.tencent.com/tcb/env/safety", "  3 - 云存储安全规则是否限制了当前登录状态访问", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + f ]
}), o("design:type", Function), o("design:paramtypes", [ Object, Function ]), o("design:returntype", Promise) ], e.prototype, "getUploadMetadata", null), 
i([ y({
customInfo: {
className: "Cloudbase",
methodName: "deleteFile"
},
title: "删除文件失败",
messages: [ "请确认以下各项：", "  1 - 调用 deleteFile() 的语法或参数是否正确", "  2 - 当前域名是否在安全域名列表中：https://console.cloud.tencent.com/tcb/env/safety", "  3 - 云存储安全规则是否限制了当前登录状态访问", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + f ]
}), o("design:type", Function), o("design:paramtypes", [ Object, Function ]), o("design:returntype", Promise) ], e.prototype, "deleteFile", null), 
i([ y({
customInfo: {
className: "Cloudbase",
methodName: "getTempFileURL"
},
title: "获取文件下载链接",
messages: [ "请确认以下各项：", "  1 - 调用 getTempFileURL() 的语法或参数是否正确", "  2 - 当前域名是否在安全域名列表中：https://console.cloud.tencent.com/tcb/env/safety", "  3 - 云存储安全规则是否限制了当前登录状态访问", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + f ]
}), o("design:type", Function), o("design:paramtypes", [ Object, Function ]), o("design:returntype", Promise) ], e.prototype, "getTempFileURL", null), 
i([ y({
customInfo: {
className: "Cloudbase",
methodName: "downloadFile"
},
title: "下载文件失败",
messages: [ "请确认以下各项：", "  1 - 调用 downloadFile() 的语法或参数是否正确", "  2 - 当前域名是否在安全域名列表中：https://console.cloud.tencent.com/tcb/env/safety", "  3 - 云存储安全规则是否限制了当前登录状态访问", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + f ]
}), o("design:type", Function), o("design:paramtypes", [ Object, Function ]), o("design:returntype", Promise) ], e.prototype, "downloadFile", null), 
e;
}())(), g = {
name: "storage",
entity: {
uploadFile: _.uploadFile,
deleteFile: _.deleteFile,
getTempFileURL: _.getTempFileURL,
downloadFile: _.downloadFile,
getUploadMetadata: _.getUploadMetadata
}
};
try {
cloudbase.registerComponent(g);
} catch (e) {}
function v(e) {
try {
e.registerComponent(g);
} catch (e) {
console.warn(e);
}
}
}, function(e) {
e.exports = function(e) {
return e.webpackPolyfill || (e.deprecate = function() {}, e.paths = [], e.children || (e.children = []), 
Object.defineProperty(e, "loaded", {
enumerable: !0,
get: function() {
return e.l;
}
}), Object.defineProperty(e, "id", {
enumerable: !0,
get: function() {
return e.i;
}
}), e.webpackPolyfill = 1), e;
};
}, function(e, t) {
"use strict";
t.byteLength = function(e) {
var t = u(e), n = t[0], r = t[1];
return 3 * (n + r) / 4 - r;
}, t.toByteArray = function(e) {
var t, n, o = u(e), s = o[0], a = o[1], c = new i(3 * (s + a) / 4 - a), f = 0, l = a > 0 ? s - 4 : s;
for (n = 0; n < l; n += 4) t = r[e.charCodeAt(n)] << 18 | r[e.charCodeAt(n + 1)] << 12 | r[e.charCodeAt(n + 2)] << 6 | r[e.charCodeAt(n + 3)], 
c[f++] = t >> 16 & 255, c[f++] = t >> 8 & 255, c[f++] = 255 & t;
2 === a && (t = r[e.charCodeAt(n)] << 2 | r[e.charCodeAt(n + 1)] >> 4, c[f++] = 255 & t);
1 === a && (t = r[e.charCodeAt(n)] << 10 | r[e.charCodeAt(n + 1)] << 4 | r[e.charCodeAt(n + 2)] >> 2, 
c[f++] = t >> 8 & 255, c[f++] = 255 & t);
return c;
}, t.fromByteArray = function(e) {
for (var t, r = e.length, i = r % 3, o = [], s = 0, a = r - i; s < a; s += 16383) o.push(c(e, s, s + 16383 > a ? a : s + 16383));
1 === i ? (t = e[r - 1], o.push(n[t >> 2] + n[t << 4 & 63] + "==")) : 2 === i && (t = (e[r - 2] << 8) + e[r - 1], 
o.push(n[t >> 10] + n[t >> 4 & 63] + n[t << 2 & 63] + "="));
return o.join("");
};
for (var n = [], r = [], i = "undefined" != typeof Uint8Array ? Uint8Array : Array, o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", s = 0, a = o.length; s < a; ++s) n[s] = o[s], 
r[o.charCodeAt(s)] = s;
function u(e) {
var t = e.length;
if (t % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");
var n = e.indexOf("=");
return -1 === n && (n = t), [ n, n === t ? 0 : 4 - n % 4 ];
}
function c(e, t, r) {
for (var i, o, s = [], a = t; a < r; a += 3) i = (e[a] << 16 & 16711680) + (e[a + 1] << 8 & 65280) + (255 & e[a + 2]), 
s.push(n[(o = i) >> 18 & 63] + n[o >> 12 & 63] + n[o >> 6 & 63] + n[63 & o]);
return s.join("");
}
r["-".charCodeAt(0)] = 62, r["_".charCodeAt(0)] = 63;
}, function(e, t) {
t.read = function(e, t, n, r, i) {
var o, s, a = 8 * i - r - 1, u = (1 << a) - 1, c = u >> 1, f = -7, l = n ? i - 1 : 0, h = n ? -1 : 1, p = e[t + l];
for (l += h, o = p & (1 << -f) - 1, p >>= -f, f += a; f > 0; o = 256 * o + e[t + l], 
l += h, f -= 8) ;
for (s = o & (1 << -f) - 1, o >>= -f, f += r; f > 0; s = 256 * s + e[t + l], l += h, 
f -= 8) ;
if (0 === o) o = 1 - c; else {
if (o === u) return s ? NaN : 1 / 0 * (p ? -1 : 1);
s += Math.pow(2, r), o -= c;
}
return (p ? -1 : 1) * s * Math.pow(2, o - r);
}, t.write = function(e, t, n, r, i, o) {
var s, a, u, c = 8 * o - i - 1, f = (1 << c) - 1, l = f >> 1, h = 23 === i ? Math.pow(2, -24) - Math.pow(2, -77) : 0, p = r ? 0 : o - 1, d = r ? 1 : -1, y = t < 0 || 0 === t && 1 / t < 0 ? 1 : 0;
for (t = Math.abs(t), isNaN(t) || t === 1 / 0 ? (a = isNaN(t) ? 1 : 0, s = f) : (s = Math.floor(Math.log(t) / Math.LN2), 
t * (u = Math.pow(2, -s)) < 1 && (s--, u *= 2), (t += s + l >= 1 ? h / u : h * Math.pow(2, 1 - l)) * u >= 2 && (s++, 
u /= 2), s + l >= f ? (a = 0, s = f) : s + l >= 1 ? (a = (t * u - 1) * Math.pow(2, i), 
s += l) : (a = t * Math.pow(2, l - 1) * Math.pow(2, i), s = 0)); i >= 8; e[n + p] = 255 & a, 
p += d, a /= 256, i -= 8) ;
for (s = s << i | a, c += i; c > 0; e[n + p] = 255 & s, p += d, s /= 256, c -= 8) ;
e[n + p - d] |= 128 * y;
};
}, function(e) {
var t = {}.toString;
e.exports = Array.isArray || function(e) {
return "[object Array]" == t.call(e);
};
}, function(e) {
e.exports = JSON.parse('{"version":"1.3.3"}');
}, function(e, t, n) {
"use strict";
n.r(t), n.d(t, "registerDatabase", function() {
return yt;
});
var r, i, o = {};
n.r(o), n.d(o, "Point", function() {
return se;
}), n.d(o, "LineString", function() {
return K;
}), n.d(o, "Polygon", function() {
return Y;
}), n.d(o, "MultiPoint", function() {
return J;
}), n.d(o, "MultiLineString", function() {
return X;
}), n.d(o, "MultiPolygon", function() {
return Z;
}), function(e) {
e.DocIDError = "文档ID不合法", e.CollNameError = "集合名称不合法", e.OpStrError = "操作符不合法", 
e.DirectionError = "排序字符不合法", e.IntergerError = "must be integer", e.QueryParamTypeError = "查询参数必须为对象", 
e.QueryParamValueError = "查询参数对象值不能均为undefined";
}(i || (i = {}));
var s, a, u = "Object", c = "GeoPoint", f = "GeoLineString", l = "GeoPolygon", h = "GeoMultiPoint", p = "GeoMultiLineString", d = "GeoMultiPolygon", y = "Date", _ = "ServerDate", g = [ "desc", "asc" ], v = [ "<", "<=", "==", ">=", ">" ];
!function(e) {
e.lt = "<", e.gt = ">", e.lte = "<=", e.gte = ">=", e.eq = "==";
}(s || (s = {}));
(r = {})[s.eq] = "$eq", r[s.lt] = "$lt", r[s.lte] = "$lte", r[s.gt] = "$gt", r[s.gte] = "$gte";
!function(e) {
e.WHERE = "WHERE", e.DOC = "DOC";
}(a || (a = {}));
var m, b = (m = function(e, t) {
return (m = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
})(e, t);
}, function(e, t) {
function n() {
this.constructor = e;
}
m(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
new n());
}), w = [], E = {}, S = function(e) {
function t(t, n) {
if (n !== E) throw new TypeError("InternalSymbol cannot be constructed with new operator");
return e.call(this, t) || this;
}
return b(t, e), t.for = function(e) {
for (var n = 0, r = w.length; n < r; n++) if (w[n].target === e) return w[n].instance;
var i = new t(e, E);
return w.push({
target: e,
instance: i
}), i;
}, t;
}(function(e) {
Object.defineProperties(this, {
target: {
enumerable: !1,
writable: !1,
configurable: !1,
value: e
}
});
}), A = S, O = A.for("UNSET_FIELD_NAME"), I = A.for("UPDATE_COMMAND"), T = A.for("QUERY_COMMAND"), N = A.for("LOGIC_COMMAND"), R = A.for("GEO_POINT"), P = A.for("SYMBOL_GEO_LINE_STRING"), B = A.for("SYMBOL_GEO_POLYGON"), D = A.for("SYMBOL_GEO_MULTI_POINT"), C = A.for("SYMBOL_GEO_MULTI_LINE_STRING"), L = A.for("SYMBOL_GEO_MULTI_POLYGON"), x = A.for("SERVER_DATE"), k = A.for("REGEXP"), U = function(e) {
return Object.prototype.toString.call(e).slice(8, -1).toLowerCase();
}, M = function(e) {
return "object" === U(e);
}, j = function(e) {
return "number" === U(e);
}, $ = function(e) {
return Array.isArray(e);
}, q = function(e) {
return "date" === U(e);
}, F = function(e) {
return "regexp" === U(e);
}, W = function(e) {
return e && e._internalType instanceof S;
}, z = function(e) {
var t = "function" == typeof Symbol && Symbol.iterator, n = t && e[t], r = 0;
if (n) return n.call(e);
if (e && "number" == typeof e.length) return {
next: function() {
return e && r >= e.length && (e = void 0), {
value: e && e[r++],
done: !e
};
}
};
throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}, K = function() {
function e(e) {
if (!$(e)) throw new TypeError('"points" must be of type Point[]. Received type ' + typeof e);
if (e.length < 2) throw new Error('"points" must contain 2 points at least');
e.forEach(function(e) {
if (!(e instanceof se)) throw new TypeError('"points" must be of type Point[]. Received type ' + typeof e + "[]");
}), this.points = e;
}
return e.prototype.parse = function(e) {
var t;
return (t = {})[e] = {
type: "LineString",
coordinates: this.points.map(function(e) {
return e.toJSON().coordinates;
})
}, t;
}, e.prototype.toJSON = function() {
return {
type: "LineString",
coordinates: this.points.map(function(e) {
return e.toJSON().coordinates;
})
};
}, e.validate = function(e) {
var t, n;
if ("LineString" !== e.type || !$(e.coordinates)) return !1;
try {
for (var r = z(e.coordinates), i = r.next(); !i.done; i = r.next()) {
var o = i.value;
if (!j(o[0]) || !j(o[1])) return !1;
}
} catch (e) {
t = {
error: e
};
} finally {
try {
i && !i.done && (n = r.return) && n.call(r);
} finally {
if (t) throw t.error;
}
}
return !0;
}, e.isClosed = function(e) {
var t = e.points[0], n = e.points[e.points.length - 1];
if (t.latitude === n.latitude && t.longitude === n.longitude) return !0;
}, Object.defineProperty(e.prototype, "_internalType", {
get: function() {
return P;
},
enumerable: !0,
configurable: !0
}), e;
}(), G = function(e) {
var t = "function" == typeof Symbol && Symbol.iterator, n = t && e[t], r = 0;
if (n) return n.call(e);
if (e && "number" == typeof e.length) return {
next: function() {
return e && r >= e.length && (e = void 0), {
value: e && e[r++],
done: !e
};
}
};
throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}, Y = function() {
function e(e) {
if (!$(e)) throw new TypeError('"lines" must be of type LineString[]. Received type ' + typeof e);
if (0 === e.length) throw new Error("Polygon must contain 1 linestring at least");
e.forEach(function(e) {
if (!(e instanceof K)) throw new TypeError('"lines" must be of type LineString[]. Received type ' + typeof e + "[]");
if (!K.isClosed(e)) throw new Error("LineString " + e.points.map(function(e) {
return e.toReadableString();
}) + " is not a closed cycle");
}), this.lines = e;
}
return e.prototype.parse = function(e) {
var t;
return (t = {})[e] = {
type: "Polygon",
coordinates: this.lines.map(function(e) {
return e.points.map(function(e) {
return [ e.longitude, e.latitude ];
});
})
}, t;
}, e.prototype.toJSON = function() {
return {
type: "Polygon",
coordinates: this.lines.map(function(e) {
return e.points.map(function(e) {
return [ e.longitude, e.latitude ];
});
})
};
}, e.validate = function(e) {
var t, n, r, i;
if ("Polygon" !== e.type || !$(e.coordinates)) return !1;
try {
for (var o = G(e.coordinates), s = o.next(); !s.done; s = o.next()) {
var a = s.value;
if (!this.isCloseLineString(a)) return !1;
try {
for (var u = (r = void 0, G(a)), c = u.next(); !c.done; c = u.next()) {
var f = c.value;
if (!j(f[0]) || !j(f[1])) return !1;
}
} catch (e) {
r = {
error: e
};
} finally {
try {
c && !c.done && (i = u.return) && i.call(u);
} finally {
if (r) throw r.error;
}
}
}
} catch (e) {
t = {
error: e
};
} finally {
try {
s && !s.done && (n = o.return) && n.call(o);
} finally {
if (t) throw t.error;
}
}
return !0;
}, e.isCloseLineString = function(e) {
var t = e[0], n = e[e.length - 1];
return t[0] === n[0] && t[1] === n[1];
}, Object.defineProperty(e.prototype, "_internalType", {
get: function() {
return L;
},
enumerable: !0,
configurable: !0
}), e;
}(), H = function(e) {
var t = "function" == typeof Symbol && Symbol.iterator, n = t && e[t], r = 0;
if (n) return n.call(e);
if (e && "number" == typeof e.length) return {
next: function() {
return e && r >= e.length && (e = void 0), {
value: e && e[r++],
done: !e
};
}
};
throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}, J = function() {
function e(e) {
if (!$(e)) throw new TypeError('"points" must be of type Point[]. Received type ' + typeof e);
if (0 === e.length) throw new Error('"points" must contain 1 point at least');
e.forEach(function(e) {
if (!(e instanceof se)) throw new TypeError('"points" must be of type Point[]. Received type ' + typeof e + "[]");
}), this.points = e;
}
return e.prototype.parse = function(e) {
var t;
return (t = {})[e] = {
type: "MultiPoint",
coordinates: this.points.map(function(e) {
return e.toJSON().coordinates;
})
}, t;
}, e.prototype.toJSON = function() {
return {
type: "MultiPoint",
coordinates: this.points.map(function(e) {
return e.toJSON().coordinates;
})
};
}, e.validate = function(e) {
var t, n;
if ("MultiPoint" !== e.type || !$(e.coordinates)) return !1;
try {
for (var r = H(e.coordinates), i = r.next(); !i.done; i = r.next()) {
var o = i.value;
if (!j(o[0]) || !j(o[1])) return !1;
}
} catch (e) {
t = {
error: e
};
} finally {
try {
i && !i.done && (n = r.return) && n.call(r);
} finally {
if (t) throw t.error;
}
}
return !0;
}, Object.defineProperty(e.prototype, "_internalType", {
get: function() {
return D;
},
enumerable: !0,
configurable: !0
}), e;
}(), V = function(e) {
var t = "function" == typeof Symbol && Symbol.iterator, n = t && e[t], r = 0;
if (n) return n.call(e);
if (e && "number" == typeof e.length) return {
next: function() {
return e && r >= e.length && (e = void 0), {
value: e && e[r++],
done: !e
};
}
};
throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}, X = function() {
function e(e) {
if (!$(e)) throw new TypeError('"lines" must be of type LineString[]. Received type ' + typeof e);
if (0 === e.length) throw new Error("Polygon must contain 1 linestring at least");
e.forEach(function(e) {
if (!(e instanceof K)) throw new TypeError('"lines" must be of type LineString[]. Received type ' + typeof e + "[]");
}), this.lines = e;
}
return e.prototype.parse = function(e) {
var t;
return (t = {})[e] = {
type: "MultiLineString",
coordinates: this.lines.map(function(e) {
return e.points.map(function(e) {
return [ e.longitude, e.latitude ];
});
})
}, t;
}, e.prototype.toJSON = function() {
return {
type: "MultiLineString",
coordinates: this.lines.map(function(e) {
return e.points.map(function(e) {
return [ e.longitude, e.latitude ];
});
})
};
}, e.validate = function(e) {
var t, n, r, i;
if ("MultiLineString" !== e.type || !$(e.coordinates)) return !1;
try {
for (var o = V(e.coordinates), s = o.next(); !s.done; s = o.next()) {
var a = s.value;
try {
for (var u = (r = void 0, V(a)), c = u.next(); !c.done; c = u.next()) {
var f = c.value;
if (!j(f[0]) || !j(f[1])) return !1;
}
} catch (e) {
r = {
error: e
};
} finally {
try {
c && !c.done && (i = u.return) && i.call(u);
} finally {
if (r) throw r.error;
}
}
}
} catch (e) {
t = {
error: e
};
} finally {
try {
s && !s.done && (n = o.return) && n.call(o);
} finally {
if (t) throw t.error;
}
}
return !0;
}, Object.defineProperty(e.prototype, "_internalType", {
get: function() {
return C;
},
enumerable: !0,
configurable: !0
}), e;
}(), Q = function(e) {
var t = "function" == typeof Symbol && Symbol.iterator, n = t && e[t], r = 0;
if (n) return n.call(e);
if (e && "number" == typeof e.length) return {
next: function() {
return e && r >= e.length && (e = void 0), {
value: e && e[r++],
done: !e
};
}
};
throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}, Z = function() {
function e(e) {
var t, n;
if (!$(e)) throw new TypeError('"polygons" must be of type Polygon[]. Received type ' + typeof e);
if (0 === e.length) throw new Error("MultiPolygon must contain 1 polygon at least");
try {
for (var r = Q(e), i = r.next(); !i.done; i = r.next()) {
var o = i.value;
if (!(o instanceof Y)) throw new TypeError('"polygon" must be of type Polygon[]. Received type ' + typeof o + "[]");
}
} catch (e) {
t = {
error: e
};
} finally {
try {
i && !i.done && (n = r.return) && n.call(r);
} finally {
if (t) throw t.error;
}
}
this.polygons = e;
}
return e.prototype.parse = function(e) {
var t;
return (t = {})[e] = {
type: "MultiPolygon",
coordinates: this.polygons.map(function(e) {
return e.lines.map(function(e) {
return e.points.map(function(e) {
return [ e.longitude, e.latitude ];
});
});
})
}, t;
}, e.prototype.toJSON = function() {
return {
type: "MultiPolygon",
coordinates: this.polygons.map(function(e) {
return e.lines.map(function(e) {
return e.points.map(function(e) {
return [ e.longitude, e.latitude ];
});
});
})
};
}, e.validate = function(e) {
var t, n, r, i, o, s;
if ("MultiPolygon" !== e.type || !$(e.coordinates)) return !1;
try {
for (var a = Q(e.coordinates), u = a.next(); !u.done; u = a.next()) {
var c = u.value;
try {
for (var f = (r = void 0, Q(c)), l = f.next(); !l.done; l = f.next()) {
var h = l.value;
try {
for (var p = (o = void 0, Q(h)), d = p.next(); !d.done; d = p.next()) {
var y = d.value;
if (!j(y[0]) || !j(y[1])) return !1;
}
} catch (e) {
o = {
error: e
};
} finally {
try {
d && !d.done && (s = p.return) && s.call(p);
} finally {
if (o) throw o.error;
}
}
}
} catch (e) {
r = {
error: e
};
} finally {
try {
l && !l.done && (i = f.return) && i.call(f);
} finally {
if (r) throw r.error;
}
}
}
} catch (e) {
t = {
error: e
};
} finally {
try {
u && !u.done && (n = a.return) && n.call(a);
} finally {
if (t) throw t.error;
}
}
return !0;
}, Object.defineProperty(e.prototype, "_internalType", {
get: function() {
return B;
},
enumerable: !0,
configurable: !0
}), e;
}(), ee = function() {
function e(e) {
var t = (void 0 === e ? {} : e).offset, n = void 0 === t ? 0 : t;
this.offset = n;
}
return Object.defineProperty(e.prototype, "_internalType", {
get: function() {
return x;
},
enumerable: !0,
configurable: !0
}), e.prototype.parse = function() {
return {
$date: {
offset: this.offset
}
};
}, e;
}();
function te(e) {
return new ee(e);
}
var ne, re = function(e, t) {
var n = "function" == typeof Symbol && e[Symbol.iterator];
if (!n) return e;
var r, i, o = n.call(e), s = [];
try {
for (;(void 0 === t || t-- > 0) && !(r = o.next()).done; ) s.push(r.value);
} catch (e) {
i = {
error: e
};
} finally {
try {
r && !r.done && (n = o.return) && n.call(o);
} finally {
if (i) throw i.error;
}
}
return s;
}, ie = function() {
function e() {}
return e.formatResDocumentData = function(t) {
return t.map(function(t) {
return e.formatField(t);
});
}, e.formatField = function(t) {
var n = Object.keys(t), r = {};
return Array.isArray(t) && (r = []), n.forEach(function(n) {
var i, o = t[n];
switch (e.whichType(o)) {
case c:
i = new se(o.coordinates[0], o.coordinates[1]);
break;

case f:
i = new K(o.coordinates.map(function(e) {
return new se(e[0], e[1]);
}));
break;

case l:
i = new Y(o.coordinates.map(function(e) {
return new K(e.map(function(e) {
var t = re(e, 2), n = t[0], r = t[1];
return new se(n, r);
}));
}));
break;

case h:
i = new J(o.coordinates.map(function(e) {
return new se(e[0], e[1]);
}));
break;

case p:
i = new X(o.coordinates.map(function(e) {
return new K(e.map(function(e) {
var t = re(e, 2), n = t[0], r = t[1];
return new se(n, r);
}));
}));
break;

case d:
i = new Z(o.coordinates.map(function(e) {
return new Y(e.map(function(e) {
return new K(e.map(function(e) {
var t = re(e, 2), n = t[0], r = t[1];
return new se(n, r);
}));
}));
}));
break;

case y:
i = new Date(1e3 * o.$timestamp);
break;

case u:
case "Array":
i = e.formatField(o);
break;

case _:
i = new Date(o.$date);
break;

default:
i = o;
}
Array.isArray(r) ? r.push(i) : r[n] = i;
}), r;
}, e.whichType = function(e) {
var t = Object.prototype.toString.call(e).slice(8, -1);
if (t === y) return "BsonDate";
if (t === u) {
if (e instanceof se) return c;
if (e instanceof Date) return y;
if (e instanceof ee) return _;
e.$timestamp ? t = y : e.$date ? t = _ : se.validate(e) ? t = c : K.validate(e) ? t = f : Y.validate(e) ? t = l : J.validate(e) ? t = h : X.validate(e) ? t = p : Z.validate(e) && (t = d);
}
return t;
}, e.generateDocId = function() {
for (var e = "ABCDEFabcdef0123456789", t = "", n = 0; n < 24; n++) t += e.charAt(Math.floor(Math.random() * e.length));
return t;
}, e;
}(), oe = function() {
function e() {}
return e.isGeopoint = function(e, t) {
if ("Number" !== ie.whichType(t)) throw new Error("Geo Point must be number type");
var n = Math.abs(t);
if ("latitude" === e && n > 90) throw new Error("latitude should be a number ranges from -90 to 90");
if ("longitude" === e && n > 180) throw new Error("longitude should be a number ranges from -180 to 180");
return !0;
}, e.isInteger = function(e, t) {
if (!Number.isInteger(t)) throw new Error(e + i.IntergerError);
return !0;
}, e.isFieldOrder = function(e) {
if (-1 === g.indexOf(e)) throw new Error(i.DirectionError);
return !0;
}, e.isFieldPath = function(e) {
if (!/^[a-zA-Z0-9-_\.]/.test(e)) throw new Error();
return !0;
}, e.isOperator = function(e) {
if (-1 === v.indexOf(e)) throw new Error(i.OpStrError);
return !0;
}, e.isCollName = function(e) {
if (!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(e)) throw new Error(i.CollNameError);
return !0;
}, e.isDocID = function(e) {
if (!/^([a-fA-F0-9]){24}$/.test(e)) throw new Error(i.DocIDError);
return !0;
}, e;
}(), se = function() {
function e(e, t) {
oe.isGeopoint("longitude", e), oe.isGeopoint("latitude", t), this.longitude = e, 
this.latitude = t;
}
return e.prototype.parse = function(e) {
var t;
return (t = {})[e] = {
type: "Point",
coordinates: [ this.longitude, this.latitude ]
}, t;
}, e.prototype.toJSON = function() {
return {
type: "Point",
coordinates: [ this.longitude, this.latitude ]
};
}, e.prototype.toReadableString = function() {
return "[" + this.longitude + "," + this.latitude + "]";
}, e.validate = function(e) {
return "Point" === e.type && $(e.coordinates) && oe.isGeopoint("longitude", e.coordinates[0]) && oe.isGeopoint("latitude", e.coordinates[1]);
}, Object.defineProperty(e.prototype, "_internalType", {
get: function() {
return R;
},
enumerable: !0,
configurable: !0
}), e;
}(), ae = function() {
var e;
if (!Promise) {
(e = function() {}).promise = {};
var t = function() {
throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.');
};
return Object.defineProperty(e.promise, "then", {
get: t
}), Object.defineProperty(e.promise, "catch", {
get: t
}), e;
}
var n = new Promise(function(t, n) {
e = function(e, r) {
return e ? n(e) : t(r);
};
});
return e.promise = n, e;
};
!function(e) {
e.SET = "set", e.REMOVE = "remove", e.INC = "inc", e.MUL = "mul", e.PUSH = "push", 
e.PULL = "pull", e.PULL_ALL = "pullAll", e.POP = "pop", e.SHIFT = "shift", e.UNSHIFT = "unshift", 
e.ADD_TO_SET = "addToSet", e.BIT = "bit", e.RENAME = "rename", e.MAX = "max", e.MIN = "min";
}(ne || (ne = {}));
var ue, ce = function() {
function e(e, t, n) {
this._internalType = I, Object.defineProperties(this, {
_internalType: {
enumerable: !1,
configurable: !1
}
}), this.operator = e, this.operands = t, this.fieldName = n || O;
}
return e.prototype._setFieldName = function(t) {
return new e(this.operator, this.operands, t);
}, e;
}();
function fe(e) {
return e && e instanceof ce && e._internalType === I;
}
!function(e) {
e.AND = "and", e.OR = "or", e.NOT = "not", e.NOR = "nor";
}(ue || (ue = {}));
var le = function() {
function e(e, t, n) {
if (this._internalType = N, Object.defineProperties(this, {
_internalType: {
enumerable: !1,
configurable: !1
}
}), this.operator = e, this.operands = t, this.fieldName = n || O, this.fieldName !== O) if (Array.isArray(t)) {
t = t.slice(), this.operands = t;
for (var r = 0, i = t.length; r < i; r++) (he(o = t[r]) || _e(o)) && (t[r] = o._setFieldName(this.fieldName));
} else {
var o;
(he(o = t) || _e(o)) && (t = o._setFieldName(this.fieldName));
}
}
return e.prototype._setFieldName = function(t) {
var n = this.operands.map(function(n) {
return n instanceof e ? n._setFieldName(t) : n;
});
return new e(this.operator, n, t);
}, e.prototype.and = function() {
for (var t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];
var r = Array.isArray(arguments[0]) ? arguments[0] : Array.from(arguments);
return r.unshift(this), new e(ue.AND, r, this.fieldName);
}, e.prototype.or = function() {
for (var t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];
var r = Array.isArray(arguments[0]) ? arguments[0] : Array.from(arguments);
return r.unshift(this), new e(ue.OR, r, this.fieldName);
}, e;
}();
function he(e) {
return e && e instanceof le && e._internalType === N;
}
var pe, de = function() {
var e = function(t, n) {
return (e = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
})(t, n);
};
return function(t, n) {
function r() {
this.constructor = t;
}
e(t, n), t.prototype = null === n ? Object.create(n) : (r.prototype = n.prototype, 
new r());
};
}();
!function(e) {
e.EQ = "eq", e.NEQ = "neq", e.GT = "gt", e.GTE = "gte", e.LT = "lt", e.LTE = "lte", 
e.IN = "in", e.NIN = "nin", e.ALL = "all", e.ELEM_MATCH = "elemMatch", e.EXISTS = "exists", 
e.SIZE = "size", e.MOD = "mod", e.GEO_NEAR = "geoNear", e.GEO_WITHIN = "geoWithin", 
e.GEO_INTERSECTS = "geoIntersects";
}(pe || (pe = {}));
var ye = function(e) {
function t(t, n, r) {
var i = e.call(this, t, n, r) || this;
return i.operator = t, i._internalType = T, i;
}
return de(t, e), t.prototype.toJSON = function() {
var e, t;
switch (this.operator) {
case pe.IN:
case pe.NIN:
return (e = {})["$" + this.operator] = this.operands, e;

default:
return (t = {})["$" + this.operator] = this.operands[0], t;
}
}, t.prototype._setFieldName = function(e) {
return new t(this.operator, this.operands, e);
}, t.prototype.eq = function(e) {
var n = new t(pe.EQ, [ e ], this.fieldName);
return this.and(n);
}, t.prototype.neq = function(e) {
var n = new t(pe.NEQ, [ e ], this.fieldName);
return this.and(n);
}, t.prototype.gt = function(e) {
var n = new t(pe.GT, [ e ], this.fieldName);
return this.and(n);
}, t.prototype.gte = function(e) {
var n = new t(pe.GTE, [ e ], this.fieldName);
return this.and(n);
}, t.prototype.lt = function(e) {
var n = new t(pe.LT, [ e ], this.fieldName);
return this.and(n);
}, t.prototype.lte = function(e) {
var n = new t(pe.LTE, [ e ], this.fieldName);
return this.and(n);
}, t.prototype.in = function(e) {
var n = new t(pe.IN, e, this.fieldName);
return this.and(n);
}, t.prototype.nin = function(e) {
var n = new t(pe.NIN, e, this.fieldName);
return this.and(n);
}, t.prototype.geoNear = function(e) {
if (!(e.geometry instanceof se)) throw new TypeError('"geometry" must be of type Point. Received type ' + typeof e.geometry);
if (void 0 !== e.maxDistance && !j(e.maxDistance)) throw new TypeError('"maxDistance" must be of type Number. Received type ' + typeof e.maxDistance);
if (void 0 !== e.minDistance && !j(e.minDistance)) throw new TypeError('"minDistance" must be of type Number. Received type ' + typeof e.minDistance);
var n = new t(pe.GEO_NEAR, [ e ], this.fieldName);
return this.and(n);
}, t.prototype.geoWithin = function(e) {
if (!(e.geometry instanceof Z || e.geometry instanceof Y)) throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type ' + typeof e.geometry);
var n = new t(pe.GEO_WITHIN, [ e ], this.fieldName);
return this.and(n);
}, t.prototype.geoIntersects = function(e) {
if (!(e.geometry instanceof se || e.geometry instanceof K || e.geometry instanceof Y || e.geometry instanceof J || e.geometry instanceof X || e.geometry instanceof Z)) throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type ' + typeof e.geometry);
var n = new t(pe.GEO_INTERSECTS, [ e ], this.fieldName);
return this.and(n);
}, t;
}(le);
function _e(e) {
return e && e instanceof ye && e._internalType === T;
}
function ge(e) {
return _e(e);
}
var ve = {};
for (var me in pe) ve[me] = "$" + me;
for (var me in ue) ve[me] = "$" + me;
for (var me in ne) ve[me] = "$" + me;
function be(e) {
return ve[e] || "$" + e;
}
ve[pe.NEQ] = "$ne", ve[ne.REMOVE] = "$unset", ve[ne.SHIFT] = "$pop", ve[ne.UNSHIFT] = "$push";
var we = function() {
return (we = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}).apply(this, arguments);
}, Ee = function(e, t) {
var n = "function" == typeof Symbol && e[Symbol.iterator];
if (!n) return e;
var r, i, o = n.call(e), s = [];
try {
for (;(void 0 === t || t-- > 0) && !(r = o.next()).done; ) s.push(r.value);
} catch (e) {
i = {
error: e
};
} finally {
try {
r && !r.done && (n = o.return) && n.call(o);
} finally {
if (i) throw i.error;
}
}
return s;
}, Se = function() {
for (var e = [], t = 0; t < arguments.length; t++) e = e.concat(Ee(arguments[t]));
return e;
};
function Ae(e) {
return function e(t, n) {
if (!W(t)) {
if (q(t)) return {
$date: +t
};
if (F(t)) return {
$regex: t.source,
$options: t.flags
};
if ($(t)) return t.map(function(t) {
if (n.indexOf(t) > -1) throw new Error("Cannot convert circular structure to JSON");
return e(t, Se(n, [ t ]));
});
if (M(t)) {
var r = we({}, t);
for (var i in r) {
if (n.indexOf(r[i]) > -1) throw new Error("Cannot convert circular structure to JSON");
r[i] = e(r[i], Se(n, [ r[i] ]));
}
return r;
}
return t;
}
switch (t._internalType) {
case R:
return t.toJSON();

case x:
case k:
return t.parse();

default:
return t.toJSON ? t.toJSON() : t;
}
}(e, [ e ]);
}
var Oe = function() {
return (Oe = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}).apply(this, arguments);
}, Ie = function(e, t) {
var n = "function" == typeof Symbol && e[Symbol.iterator];
if (!n) return e;
var r, i, o = n.call(e), s = [];
try {
for (;(void 0 === t || t-- > 0) && !(r = o.next()).done; ) s.push(r.value);
} catch (e) {
i = {
error: e
};
} finally {
try {
r && !r.done && (n = o.return) && n.call(o);
} finally {
if (i) throw i.error;
}
}
return s;
}, Te = function() {
for (var e = [], t = 0; t < arguments.length; t++) e = e.concat(Ie(arguments[t]));
return e;
};
function Ne(e, t, n, r) {
var i = Oe({}, e);
for (var o in e) if (!/^\$/.test(o)) {
var s = e[o];
if (s && M(s) && !t(s)) {
if (r.indexOf(s) > -1) throw new Error("Cannot convert circular structure to JSON");
var a = Ne(s, t, Te(n, [ o ]), Te(r, [ s ]));
i[o] = a;
var u = !1;
for (var c in a) /^\$/.test(c) ? u = !0 : (i[o + "." + c] = a[c], delete i[o][c]);
u || delete i[o];
}
}
return i;
}
function Re(e) {
return Ne(e, Be, [], [ e ]);
}
function Pe(e, t, n) {
for (var r in t[n] || delete e[n], t) e[r] ? $(e[r]) ? e[r].push(t[r]) : M(e[r]) ? M(t[r]) ? Object.assign(e[r], t[r]) : (console.warn("unmergable condition, query is object but condition is " + U(t) + ", can only overwrite", t, n), 
e[r] = t[r]) : (console.warn("to-merge query is of type " + U(e) + ", can only overwrite", e, t, n), 
e[r] = t[r]) : e[r] = t[r];
}
function Be(e) {
return W(e) || q(e) || F(e);
}
function De(e) {
return Ae(e);
}
var Ce = function() {
function e() {}
return e.encode = function(t) {
return new e().encodeUpdate(t);
}, e.prototype.encodeUpdate = function(e) {
return fe(e) ? this.encodeUpdateCommand(e) : "object" === U(e) ? this.encodeUpdateObject(e) : e;
}, e.prototype.encodeUpdateCommand = function(e) {
if (e.fieldName === O) throw new Error("Cannot encode a comparison command with unset field name");
switch (e.operator) {
case ne.PUSH:
case ne.PULL:
case ne.PULL_ALL:
case ne.POP:
case ne.SHIFT:
case ne.UNSHIFT:
case ne.ADD_TO_SET:
return this.encodeArrayUpdateCommand(e);

default:
return this.encodeFieldUpdateCommand(e);
}
}, e.prototype.encodeFieldUpdateCommand = function(e) {
var t, n, r, i, o = be(e.operator);
switch (e.operator) {
case ne.REMOVE:
return (t = {})[o] = ((n = {})[e.fieldName] = "", n), t;

default:
return (r = {})[o] = ((i = {})[e.fieldName] = e.operands[0], i), r;
}
}, e.prototype.encodeArrayUpdateCommand = function(e) {
var t, n, r, i, o, s, a, u, c, f, l = be(e.operator);
switch (e.operator) {
case ne.PUSH:
var h = void 0;
return h = $(e.operands) ? {
$each: e.operands.map(De)
} : e.operands, (t = {})[l] = ((n = {})[e.fieldName] = h, n), t;

case ne.UNSHIFT:
h = {
$each: e.operands.map(De),
$position: 0
};
return (r = {})[l] = ((i = {})[e.fieldName] = h, i), r;

case ne.POP:
return (o = {})[l] = ((s = {})[e.fieldName] = 1, s), o;

case ne.SHIFT:
return (a = {})[l] = ((u = {})[e.fieldName] = -1, u), a;

default:
return (c = {})[l] = ((f = {})[e.fieldName] = De(e.operands), f), c;
}
}, e.prototype.encodeUpdateObject = function(e) {
var t = Re(e);
for (var n in t) if (!/^\$/.test(n)) {
var r = t[n];
if (fe(r)) t[n] = r._setFieldName(n), Pe(t, this.encodeUpdateCommand(t[n]), n); else {
t[n] = r = De(r);
var i = new ce(ne.SET, [ r ], n);
Pe(t, this.encodeUpdateCommand(i), n);
}
}
return t;
}, e;
}(), Le = {};
function xe(e) {
if (!ht.wsClientClass) throw new Error("to use realtime you must import realtime module first");
var t = e.config.env;
return Le[t] || (Le[t] = new ht.wsClientClass({
context: {
appConfig: {
docSizeLimit: 1e3,
realtimePingInterval: 1e4,
realtimePongWaitTimeout: 5e3,
request: new ht.reqClass(e.config)
}
}
})), Le[t];
}
var ke = function() {
return (ke = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}).apply(this, arguments);
}, Ue = function() {
function e(e, t, n, r) {
var i = this;
void 0 === r && (r = {}), this.watch = function(e) {
return xe(i._db).watch(ke(ke({}, e), {
envId: i._db.config.env,
collectionName: i._coll,
query: JSON.stringify({
_id: i.id
})
}));
}, this._db = e, this._coll = t, this.id = n, this.request = new ht.reqClass(this._db.config), 
this.projection = r;
}
return e.prototype.create = function(e, t) {
t = t || ae();
var n = {
collectionName: this._coll,
data: Ae(e)
};
return this.id && (n._id = this.id), this.request.send("database.addDocument", n).then(function(e) {
e.code ? t(0, e) : t(0, {
id: e.data._id,
requestId: e.requestId
});
}).catch(function(e) {
t(e);
}), t.promise;
}, e.prototype.set = function(e, t) {
if (t = t || ae(), !this.id) return Promise.resolve({
code: "INVALID_PARAM",
message: "docId不能为空"
});
if (!e || "object" != typeof e) return Promise.resolve({
code: "INVALID_PARAM",
message: "参数必需是非空对象"
});
if (e.hasOwnProperty("_id")) return Promise.resolve({
code: "INVALID_PARAM",
message: "不能更新_id的值"
});
var n = !1, r = function(e) {
if ("object" == typeof e) for (var t in e) e[t] instanceof ce ? n = !0 : "object" == typeof e[t] && r(e[t]);
};
if (r(e), n) return Promise.resolve({
code: "DATABASE_REQUEST_FAILED",
message: "update operator complicit"
});
var i = {
collectionName: this._coll,
queryType: a.DOC,
data: Ae(e),
multi: !1,
merge: !1,
upsert: !0
};
return this.id && (i.query = {
_id: this.id
}), this.request.send("database.updateDocument", i).then(function(e) {
e.code ? t(0, e) : t(0, {
updated: e.data.updated,
upsertedId: e.data.upserted_id,
requestId: e.requestId
});
}).catch(function(e) {
t(e);
}), t.promise;
}, e.prototype.update = function(e, t) {
if (t = t || ae(), !e || "object" != typeof e) return Promise.resolve({
code: "INVALID_PARAM",
message: "参数必需是非空对象"
});
if (e.hasOwnProperty("_id")) return Promise.resolve({
code: "INVALID_PARAM",
message: "不能更新_id的值"
});
var n = {
_id: this.id
}, r = {
collectionName: this._coll,
data: Ce.encode(e),
query: n,
queryType: a.DOC,
multi: !1,
merge: !0,
upsert: !1
};
return this.request.send("database.updateDocument", r).then(function(e) {
e.code ? t(0, e) : t(0, {
updated: e.data.updated,
upsertedId: e.data.upserted_id,
requestId: e.requestId
});
}).catch(function(e) {
t(e);
}), t.promise;
}, e.prototype.remove = function(e) {
e = e || ae();
var t = {
_id: this.id
}, n = {
collectionName: this._coll,
query: t,
queryType: a.DOC,
multi: !1
};
return this.request.send("database.deleteDocument", n).then(function(t) {
t.code ? e(0, t) : e(0, {
deleted: t.data.deleted,
requestId: t.requestId
});
}).catch(function(t) {
e(t);
}), e.promise;
}, e.prototype.get = function(e) {
e = e || ae();
var t = {
_id: this.id
}, n = {
collectionName: this._coll,
query: t,
queryType: a.DOC,
multi: !1,
projection: this.projection
};
return this.request.send("database.queryDocument", n).then(function(t) {
if (t.code) e(0, t); else {
var n = ie.formatResDocumentData(t.data.list);
e(0, {
data: n,
requestId: t.requestId,
total: t.TotalCount,
limit: t.Limit,
offset: t.Offset
});
}
}).catch(function(t) {
e(t);
}), e.promise;
}, e.prototype.field = function(t) {
for (var n in t) t[n] ? t[n] = 1 : t[n] = 0;
return new e(this._db, this._coll, this.id, t);
}, e;
}(), Me = function() {
function e() {}
return e.encode = function(e) {
return new je().encodeQuery(e);
}, e;
}(), je = function() {
function e() {}
return e.prototype.encodeQuery = function(e, t) {
var n;
return Be(e) ? he(e) ? this.encodeLogicCommand(e) : _e(e) ? this.encodeQueryCommand(e) : ((n = {})[t] = this.encodeQueryObject(e), 
n) : M(e) ? this.encodeQueryObject(e) : e;
}, e.prototype.encodeRegExp = function(e) {
return {
$regex: e.source,
$options: e.flags
};
}, e.prototype.encodeLogicCommand = function(e) {
var t, n, r, i, o, s, a, u = this;
switch (e.operator) {
case ue.NOR:
case ue.AND:
case ue.OR:
var c = be(e.operator), f = e.operands.map(function(t) {
return u.encodeQuery(t, e.fieldName);
});
return (t = {})[c] = f, t;

case ue.NOT:
c = be(e.operator);
var l = e.operands[0];
if (F(l)) return (n = {})[e.fieldName] = ((r = {})[c] = this.encodeRegExp(l), r), 
n;
f = this.encodeQuery(l)[e.fieldName];
return (i = {})[e.fieldName] = ((o = {})[c] = f, o), i;

default:
c = be(e.operator);
if (1 === e.operands.length) {
var h = this.encodeQuery(e.operands[0]);
return (s = {})[c] = h, s;
}
f = e.operands.map(this.encodeQuery.bind(this));
return (a = {})[c] = f, a;
}
}, e.prototype.encodeQueryCommand = function(e) {
return ge(e), this.encodeComparisonCommand(e);
}, e.prototype.encodeComparisonCommand = function(e) {
var t, n, r, i, o, s, a, u, c;
if (e.fieldName === O) throw new Error("Cannot encode a comparison command with unset field name");
var f = be(e.operator);
switch (e.operator) {
case pe.EQ:
case pe.NEQ:
case pe.LT:
case pe.LTE:
case pe.GT:
case pe.GTE:
case pe.ELEM_MATCH:
case pe.EXISTS:
case pe.SIZE:
case pe.MOD:
return (t = {})[e.fieldName] = ((n = {})[f] = De(e.operands[0]), n), t;

case pe.IN:
case pe.NIN:
case pe.ALL:
return (r = {})[e.fieldName] = ((i = {})[f] = De(e.operands), i), r;

case pe.GEO_NEAR:
var l = e.operands[0];
return (o = {})[e.fieldName] = {
$nearSphere: {
$geometry: l.geometry.toJSON(),
$maxDistance: l.maxDistance,
$minDistance: l.minDistance
}
}, o;

case pe.GEO_WITHIN:
l = e.operands[0];
return (s = {})[e.fieldName] = {
$geoWithin: {
$geometry: l.geometry.toJSON()
}
}, s;

case pe.GEO_INTERSECTS:
l = e.operands[0];
return (a = {})[e.fieldName] = {
$geoIntersects: {
$geometry: l.geometry.toJSON()
}
}, a;

default:
return (u = {})[e.fieldName] = ((c = {})[f] = De(e.operands[0]), c), u;
}
}, e.prototype.encodeQueryObject = function(e) {
var t = Re(e);
for (var n in t) {
var r = t[n];
if (he(r)) {
t[n] = r._setFieldName(n);
var i = this.encodeLogicCommand(t[n]);
this.mergeConditionAfterEncode(t, i, n);
} else if (ge(r)) {
t[n] = r._setFieldName(n);
i = this.encodeComparisonCommand(t[n]);
this.mergeConditionAfterEncode(t, i, n);
} else Be(r) && (t[n] = De(r));
}
return t;
}, e.prototype.mergeConditionAfterEncode = function(e, t, n) {
for (var r in t[n] || delete e[n], t) e[r] ? $(e[r]) ? e[r] = e[r].concat(t[r]) : M(e[r]) ? M(t[r]) ? Object.assign(e, t) : (console.warn("unmergable condition, query is object but condition is " + U(t) + ", can only overwrite", t, n), 
e[r] = t[r]) : (console.warn("to-merge query is of type " + U(e) + ", can only overwrite", e, t, n), 
e[r] = t[r]) : e[r] = t[r];
}, e;
}(), $e = function() {
return ($e = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}).apply(this, arguments);
}, qe = function() {
function e(e, t, n, r, i) {
var o = this;
this.watch = function(e) {
return xe(o._db).watch($e($e({}, e), {
envId: o._db.config.env,
collectionName: o._coll,
query: JSON.stringify(o._fieldFilters || {}),
limit: o._queryOptions.limit,
orderBy: o._fieldOrders ? o._fieldOrders.reduce(function(e, t) {
return e[t.field] = t.direction, e;
}, {}) : void 0
}));
}, this._db = e, this._coll = t, this._fieldFilters = n, this._fieldOrders = r || [], 
this._queryOptions = i || {}, this._request = new ht.reqClass(this._db.config);
}
return e.prototype.get = function(e) {
e = e || ae();
var t = [];
this._fieldOrders && this._fieldOrders.forEach(function(e) {
t.push(e);
});
var n = {
collectionName: this._coll,
queryType: a.WHERE
};
return this._fieldFilters && (n.query = this._fieldFilters), t.length > 0 && (n.order = t), 
this._queryOptions.offset && (n.offset = this._queryOptions.offset), this._queryOptions.limit ? n.limit = this._queryOptions.limit < 1e3 ? this._queryOptions.limit : 1e3 : n.limit = 100, 
this._queryOptions.projection && (n.projection = this._queryOptions.projection), 
this._request.send("database.queryDocument", n).then(function(t) {
if (t.code) e(0, t); else {
var n = {
data: ie.formatResDocumentData(t.data.list),
requestId: t.requestId
};
t.TotalCount && (n.total = t.TotalCount), t.Limit && (n.limit = t.Limit), t.Offset && (n.offset = t.Offset), 
e(0, n);
}
}).catch(function(t) {
e(t);
}), e.promise;
}, e.prototype.count = function(e) {
e = e || ae();
var t = {
collectionName: this._coll,
queryType: a.WHERE
};
return this._fieldFilters && (t.query = this._fieldFilters), this._request.send("database.countDocument", t).then(function(t) {
t.code ? e(0, t) : e(0, {
requestId: t.requestId,
total: t.data.total
});
}).catch(function(t) {
e(t);
}), e.promise;
}, e.prototype.where = function(t) {
if ("Object" !== Object.prototype.toString.call(t).slice(8, -1)) throw Error(i.QueryParamTypeError);
var n = Object.keys(t), r = n.some(function(e) {
return void 0 !== t[e];
});
if (n.length && !r) throw Error(i.QueryParamValueError);
return new e(this._db, this._coll, Me.encode(t), this._fieldOrders, this._queryOptions);
}, e.prototype.orderBy = function(t, n) {
oe.isFieldPath(t), oe.isFieldOrder(n);
var r = {
field: t,
direction: n
}, i = this._fieldOrders.concat(r);
return new e(this._db, this._coll, this._fieldFilters, i, this._queryOptions);
}, e.prototype.limit = function(t) {
oe.isInteger("limit", t);
var n = $e({}, this._queryOptions);
return n.limit = t, new e(this._db, this._coll, this._fieldFilters, this._fieldOrders, n);
}, e.prototype.skip = function(t) {
oe.isInteger("offset", t);
var n = $e({}, this._queryOptions);
return n.offset = t, new e(this._db, this._coll, this._fieldFilters, this._fieldOrders, n);
}, e.prototype.update = function(e, t) {
if (t = t || ae(), !e || "object" != typeof e) return Promise.resolve({
code: "INVALID_PARAM",
message: "参数必需是非空对象"
});
if (e.hasOwnProperty("_id")) return Promise.resolve({
code: "INVALID_PARAM",
message: "不能更新_id的值"
});
var n = {
collectionName: this._coll,
query: this._fieldFilters,
queryType: a.WHERE,
multi: !0,
merge: !0,
upsert: !1,
data: Ce.encode(e)
};
return this._request.send("database.updateDocument", n).then(function(e) {
e.code ? t(0, e) : t(0, {
requestId: e.requestId,
updated: e.data.updated,
upsertId: e.data.upsert_id
});
}).catch(function(e) {
t(e);
}), t.promise;
}, e.prototype.field = function(t) {
for (var n in t) t[n] ? "object" != typeof t[n] && (t[n] = 1) : t[n] = 0;
var r = $e({}, this._queryOptions);
return r.projection = t, new e(this._db, this._coll, this._fieldFilters, this._fieldOrders, r);
}, e.prototype.remove = function(e) {
e = e || ae(), Object.keys(this._queryOptions).length > 0 && console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"), 
this._fieldOrders.length > 0 && console.warn("`orderBy` is not supported in remove() operation");
var t = {
collectionName: this._coll,
query: Me.encode(this._fieldFilters),
queryType: a.WHERE,
multi: !0
};
return this._request.send("database.deleteDocument", t).then(function(t) {
t.code ? e(0, t) : e(0, {
requestId: t.requestId,
deleted: t.data.deleted
});
}).catch(function(t) {
e(t);
}), e.promise;
}, e;
}(), Fe = n(1), We = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, ze = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, Ke = function() {
function e(e, t) {
this._stages = [], e && t && (this._db = e, this._request = new ht.reqClass(this._db.config), 
this._collectionName = t);
}
return e.prototype.end = function() {
return We(this, void 0, void 0, function() {
var e;
return ze(this, function(t) {
switch (t.label) {
case 0:
if (!this._collectionName || !this._db) throw new Error("Aggregation pipeline cannot send request");
return [ 4, this._request.send("database.aggregate", {
collectionName: this._collectionName,
stages: this._stages
}) ];

case 1:
return (e = t.sent()) && e.data && e.data.list ? [ 2, {
requestId: e.requestId,
data: JSON.parse(e.data.list).map(Fe.a.parse)
} ] : [ 2, e ];
}
});
});
}, e.prototype.unwrap = function() {
return this._stages;
}, e.prototype.done = function() {
return this._stages.map(function(e) {
var t, n = e.stageKey, r = e.stageValue;
return (t = {})[n] = JSON.parse(r), t;
});
}, e.prototype._pipe = function(e, t) {
return this._stages.push({
stageKey: "$" + e,
stageValue: JSON.stringify(t)
}), this;
}, e.prototype.addFields = function(e) {
return this._pipe("addFields", e);
}, e.prototype.bucket = function(e) {
return this._pipe("bucket", e);
}, e.prototype.bucketAuto = function(e) {
return this._pipe("bucketAuto", e);
}, e.prototype.count = function(e) {
return this._pipe("count", e);
}, e.prototype.geoNear = function(e) {
return this._pipe("geoNear", e);
}, e.prototype.group = function(e) {
return this._pipe("group", e);
}, e.prototype.limit = function(e) {
return this._pipe("limit", e);
}, e.prototype.match = function(e) {
return this._pipe("match", Me.encode(e));
}, e.prototype.project = function(e) {
return this._pipe("project", e);
}, e.prototype.lookup = function(e) {
return this._pipe("lookup", e);
}, e.prototype.replaceRoot = function(e) {
return this._pipe("replaceRoot", e);
}, e.prototype.sample = function(e) {
return this._pipe("sample", e);
}, e.prototype.skip = function(e) {
return this._pipe("skip", e);
}, e.prototype.sort = function(e) {
return this._pipe("sort", e);
}, e.prototype.sortByCount = function(e) {
return this._pipe("sortByCount", e);
}, e.prototype.unwind = function(e) {
return this._pipe("unwind", e);
}, e;
}(), Ge = function() {
var e = function(t, n) {
return (e = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
})(t, n);
};
return function(t, n) {
function r() {
this.constructor = t;
}
e(t, n), t.prototype = null === n ? Object.create(n) : (r.prototype = n.prototype, 
new r());
};
}(), Ye = function(e) {
function t(t, n) {
return e.call(this, t, n) || this;
}
return Ge(t, e), Object.defineProperty(t.prototype, "name", {
get: function() {
return this._coll;
},
enumerable: !0,
configurable: !0
}), t.prototype.doc = function(e) {
if ("string" != typeof e && "number" != typeof e) throw new Error("docId必须为字符串或数字");
return new Ue(this._db, this._coll, e);
}, t.prototype.add = function(e, t) {
return new Ue(this._db, this._coll, void 0).create(e, t);
}, t.prototype.aggregate = function() {
return new Ke(this._db, this._coll);
}, t;
}(qe), He = {
eq: function(e) {
return new ye(pe.EQ, [ e ]);
},
neq: function(e) {
return new ye(pe.NEQ, [ e ]);
},
lt: function(e) {
return new ye(pe.LT, [ e ]);
},
lte: function(e) {
return new ye(pe.LTE, [ e ]);
},
gt: function(e) {
return new ye(pe.GT, [ e ]);
},
gte: function(e) {
return new ye(pe.GTE, [ e ]);
},
in: function(e) {
return new ye(pe.IN, e);
},
nin: function(e) {
return new ye(pe.NIN, e);
},
all: function(e) {
return new ye(pe.ALL, e);
},
elemMatch: function(e) {
return new ye(pe.ELEM_MATCH, [ e ]);
},
exists: function(e) {
return new ye(pe.EXISTS, [ e ]);
},
size: function(e) {
return new ye(pe.SIZE, [ e ]);
},
mod: function(e) {
return new ye(pe.MOD, [ e ]);
},
geoNear: function(e) {
return new ye(pe.GEO_NEAR, [ e ]);
},
geoWithin: function(e) {
return new ye(pe.GEO_WITHIN, [ e ]);
},
geoIntersects: function(e) {
return new ye(pe.GEO_INTERSECTS, [ e ]);
},
and: function() {
for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
var n = $(arguments[0]) ? arguments[0] : Array.from(arguments);
return new le(ue.AND, n);
},
nor: function() {
for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
var n = $(arguments[0]) ? arguments[0] : Array.from(arguments);
return new le(ue.NOR, n);
},
or: function() {
for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
var n = $(arguments[0]) ? arguments[0] : Array.from(arguments);
return new le(ue.OR, n);
},
not: function() {
for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
var n = $(arguments[0]) ? arguments[0] : Array.from(arguments);
return new le(ue.NOT, n);
},
set: function(e) {
return new ce(ne.SET, [ e ]);
},
remove: function() {
return new ce(ne.REMOVE, []);
},
inc: function(e) {
return new ce(ne.INC, [ e ]);
},
mul: function(e) {
return new ce(ne.MUL, [ e ]);
},
push: function() {
for (var e, t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];
if (M(t[0]) && t[0].hasOwnProperty("each")) {
var r = t[0];
e = {
$each: r.each,
$position: r.position,
$sort: r.sort,
$slice: r.slice
};
} else e = $(t[0]) ? t[0] : Array.from(t);
return new ce(ne.PUSH, e);
},
pull: function(e) {
return new ce(ne.PULL, e);
},
pullAll: function(e) {
return new ce(ne.PULL_ALL, e);
},
pop: function() {
return new ce(ne.POP, []);
},
shift: function() {
return new ce(ne.SHIFT, []);
},
unshift: function() {
for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
var n = $(arguments[0]) ? arguments[0] : Array.from(arguments);
return new ce(ne.UNSHIFT, n);
},
addToSet: function(e) {
return new ce(ne.ADD_TO_SET, e);
},
rename: function(e) {
return new ce(ne.RENAME, [ e ]);
},
bit: function(e) {
return new ce(ne.BIT, [ e ]);
},
max: function(e) {
return new ce(ne.MAX, [ e ]);
},
min: function(e) {
return new ce(ne.MIN, [ e ]);
},
expr: function(e) {
return {
$expr: e
};
},
jsonSchema: function(e) {
return {
$jsonSchema: e
};
},
text: function(e) {
return "string" === U(e) ? {
$search: e.search
} : {
$search: e.search,
$language: e.language,
$caseSensitive: e.caseSensitive,
$diacriticSensitive: e.diacriticSensitive
};
},
aggregate: {
pipeline: function() {
return new Ke();
},
abs: function(e) {
return new Je("abs", e);
},
add: function(e) {
return new Je("add", e);
},
ceil: function(e) {
return new Je("ceil", e);
},
divide: function(e) {
return new Je("divide", e);
},
exp: function(e) {
return new Je("exp", e);
},
floor: function(e) {
return new Je("floor", e);
},
ln: function(e) {
return new Je("ln", e);
},
log: function(e) {
return new Je("log", e);
},
log10: function(e) {
return new Je("log10", e);
},
mod: function(e) {
return new Je("mod", e);
},
multiply: function(e) {
return new Je("multiply", e);
},
pow: function(e) {
return new Je("pow", e);
},
sqrt: function(e) {
return new Je("sqrt", e);
},
subtract: function(e) {
return new Je("subtract", e);
},
trunc: function(e) {
return new Je("trunc", e);
},
arrayElemAt: function(e) {
return new Je("arrayElemAt", e);
},
arrayToObject: function(e) {
return new Je("arrayToObject", e);
},
concatArrays: function(e) {
return new Je("concatArrays", e);
},
filter: function(e) {
return new Je("filter", e);
},
in: function(e) {
return new Je("in", e);
},
indexOfArray: function(e) {
return new Je("indexOfArray", e);
},
isArray: function(e) {
return new Je("isArray", e);
},
map: function(e) {
return new Je("map", e);
},
range: function(e) {
return new Je("range", e);
},
reduce: function(e) {
return new Je("reduce", e);
},
reverseArray: function(e) {
return new Je("reverseArray", e);
},
size: function(e) {
return new Je("size", e);
},
slice: function(e) {
return new Je("slice", e);
},
zip: function(e) {
return new Je("zip", e);
},
and: function(e) {
return new Je("and", e);
},
not: function(e) {
return new Je("not", e);
},
or: function(e) {
return new Je("or", e);
},
cmp: function(e) {
return new Je("cmp", e);
},
eq: function(e) {
return new Je("eq", e);
},
gt: function(e) {
return new Je("gt", e);
},
gte: function(e) {
return new Je("gte", e);
},
lt: function(e) {
return new Je("lt", e);
},
lte: function(e) {
return new Je("lte", e);
},
neq: function(e) {
return new Je("ne", e);
},
cond: function(e) {
return new Je("cond", e);
},
ifNull: function(e) {
return new Je("ifNull", e);
},
switch: function(e) {
return new Je("switch", e);
},
dateFromParts: function(e) {
return new Je("dateFromParts", e);
},
dateFromString: function(e) {
return new Je("dateFromString", e);
},
dayOfMonth: function(e) {
return new Je("dayOfMonth", e);
},
dayOfWeek: function(e) {
return new Je("dayOfWeek", e);
},
dayOfYear: function(e) {
return new Je("dayOfYear", e);
},
isoDayOfWeek: function(e) {
return new Je("isoDayOfWeek", e);
},
isoWeek: function(e) {
return new Je("isoWeek", e);
},
isoWeekYear: function(e) {
return new Je("isoWeekYear", e);
},
millisecond: function(e) {
return new Je("millisecond", e);
},
minute: function(e) {
return new Je("minute", e);
},
month: function(e) {
return new Je("month", e);
},
second: function(e) {
return new Je("second", e);
},
hour: function(e) {
return new Je("hour", e);
},
week: function(e) {
return new Je("week", e);
},
year: function(e) {
return new Je("year", e);
},
literal: function(e) {
return new Je("literal", e);
},
mergeObjects: function(e) {
return new Je("mergeObjects", e);
},
objectToArray: function(e) {
return new Je("objectToArray", e);
},
allElementsTrue: function(e) {
return new Je("allElementsTrue", e);
},
anyElementTrue: function(e) {
return new Je("anyElementTrue", e);
},
setDifference: function(e) {
return new Je("setDifference", e);
},
setEquals: function(e) {
return new Je("setEquals", e);
},
setIntersection: function(e) {
return new Je("setIntersection", e);
},
setIsSubset: function(e) {
return new Je("setIsSubset", e);
},
setUnion: function(e) {
return new Je("setUnion", e);
},
concat: function(e) {
return new Je("concat", e);
},
dateToString: function(e) {
return new Je("dateToString", e);
},
indexOfBytes: function(e) {
return new Je("indexOfBytes", e);
},
indexOfCP: function(e) {
return new Je("indexOfCP", e);
},
split: function(e) {
return new Je("split", e);
},
strLenBytes: function(e) {
return new Je("strLenBytes", e);
},
strLenCP: function(e) {
return new Je("strLenCP", e);
},
strcasecmp: function(e) {
return new Je("strcasecmp", e);
},
substr: function(e) {
return new Je("substr", e);
},
substrBytes: function(e) {
return new Je("substrBytes", e);
},
substrCP: function(e) {
return new Je("substrCP", e);
},
toLower: function(e) {
return new Je("toLower", e);
},
toUpper: function(e) {
return new Je("toUpper", e);
},
meta: function(e) {
return new Je("meta", e);
},
addToSet: function(e) {
return new Je("addToSet", e);
},
avg: function(e) {
return new Je("avg", e);
},
first: function(e) {
return new Je("first", e);
},
last: function(e) {
return new Je("last", e);
},
max: function(e) {
return new Je("max", e);
},
min: function(e) {
return new Je("min", e);
},
push: function(e) {
return new Je("push", e);
},
stdDevPop: function(e) {
return new Je("stdDevPop", e);
},
stdDevSamp: function(e) {
return new Je("stdDevSamp", e);
},
sum: function(e) {
return new Je("sum", e);
},
let: function(e) {
return new Je("let", e);
}
},
project: {
slice: function(e) {
return new Ve("slice", e);
},
elemMatch: function(e) {
return new Ve("elemMatch", e);
}
}
}, Je = function(e, t) {
this["$" + e] = t;
}, Ve = function(e, t) {
this["$" + e] = t;
}, Xe = function() {
function e(e) {
var t = e.regexp, n = e.options;
if (!t) throw new TypeError("regexp must be a string");
this.$regex = t, this.$options = n;
}
return e.prototype.parse = function() {
return {
$regex: this.$regex,
$options: this.$options
};
}, Object.defineProperty(e.prototype, "_internalType", {
get: function() {
return k;
},
enumerable: !0,
configurable: !0
}), e;
}();
function Qe(e) {
return new Xe(e);
}
var Ze = {
code: "DATABASE_TRANSACTION_CONFLICT",
message: "database transaction conflict"
}, et = function() {
return (et = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}).apply(this, arguments);
}, tt = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, nt = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, rt = "database.updateDocInTransaction", it = function() {
function e(e, t, n) {
this._coll = t, this.id = n, this._transaction = e, this._request = this._transaction.getRequestMethod(), 
this._transactionId = this._transaction.getTransactionId();
}
return e.prototype.create = function(e) {
return tt(this, void 0, void 0, function() {
var t, n, r, i;
return nt(this, function(o) {
switch (o.label) {
case 0:
return t = {
collectionName: this._coll,
transactionId: this._transactionId,
data: Fe.a.stringify(Ae(e), {
relaxed: !1
})
}, this.id && (t._id = this.id), [ 4, this._request.send("database.insertDocInTransaction", t) ];

case 1:
if ((n = o.sent()).code) throw n;
if (r = Fe.a.parse(n.inserted), 1 == (i = Fe.a.parse(n.ok)) && 1 == r) return [ 2, et(et({}, n), {
ok: i,
inserted: r
}) ];
throw new Error("insert document failed");
}
});
});
}, e.prototype.get = function() {
return tt(this, void 0, void 0, function() {
var e, t;
return nt(this, function(n) {
switch (n.label) {
case 0:
return e = {
collectionName: this._coll,
transactionId: this._transactionId,
query: {
_id: {
$eq: this.id
}
}
}, [ 4, this._request.send("database.getInTransaction", e) ];

case 1:
if ((t = n.sent()).code) throw t;
return [ 2, {
data: "null" !== t.data ? ie.formatField(Fe.a.parse(t.data)) : Fe.a.parse(t.data),
requestId: t.requestId
} ];
}
});
});
}, e.prototype.set = function(e) {
return tt(this, void 0, void 0, function() {
var t, n;
return nt(this, function(r) {
switch (r.label) {
case 0:
return t = {
collectionName: this._coll,
transactionId: this._transactionId,
query: {
_id: {
$eq: this.id
}
},
data: Fe.a.stringify(Ae(e), {
relaxed: !1
}),
upsert: !0
}, [ 4, this._request.send(rt, t) ];

case 1:
if ((n = r.sent()).code) throw n;
return [ 2, et(et({}, n), {
updated: Fe.a.parse(n.updated),
upserted: n.upserted ? JSON.parse(n.upserted) : null
}) ];
}
});
});
}, e.prototype.update = function(e) {
return tt(this, void 0, void 0, function() {
var t, n;
return nt(this, function(r) {
switch (r.label) {
case 0:
return t = {
collectionName: this._coll,
transactionId: this._transactionId,
query: {
_id: {
$eq: this.id
}
},
data: Fe.a.stringify(Ce.encode(e), {
relaxed: !1
})
}, [ 4, this._request.send(rt, t) ];

case 1:
if ((n = r.sent()).code) throw n;
return [ 2, et(et({}, n), {
updated: Fe.a.parse(n.updated)
}) ];
}
});
});
}, e.prototype.delete = function() {
return tt(this, void 0, void 0, function() {
var e, t;
return nt(this, function(n) {
switch (n.label) {
case 0:
return e = {
collectionName: this._coll,
transactionId: this._transactionId,
query: {
_id: {
$eq: this.id
}
}
}, [ 4, this._request.send("database.deleteDocInTransaction", e) ];

case 1:
if ((t = n.sent()).code) throw t;
return [ 2, et(et({}, t), {
deleted: Fe.a.parse(t.deleted)
}) ];
}
});
});
}, e;
}(), ot = function() {
var e = function(t, n) {
return (e = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
})(t, n);
};
return function(t, n) {
function r() {
this.constructor = t;
}
e(t, n), t.prototype = null === n ? Object.create(n) : (r.prototype = n.prototype, 
new r());
};
}(), st = function(e) {
function t(t, n) {
return e.call(this, t, n) || this;
}
return ot(t, e), Object.defineProperty(t.prototype, "name", {
get: function() {
return this._coll;
},
enumerable: !0,
configurable: !0
}), t.prototype.doc = function(e) {
if ("string" != typeof e && "number" != typeof e) throw new Error("docId必须为字符串或数字");
return new it(this._transaction, this._coll, e);
}, t.prototype.add = function(e) {
var t;
return void 0 !== e._id && (t = e._id), new it(this._transaction, this._coll, t).create(e);
}, t;
}(function(e, t) {
this._coll = t, this._transaction = e;
}), at = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, ut = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, ct = function() {
function e(e) {
this._db = e, this._request = new ht.reqClass(this._db.config), this.aborted = !1, 
this.commited = !1, this.inited = !1;
}
return e.prototype.init = function() {
return at(this, void 0, void 0, function() {
var e;
return ut(this, function(t) {
switch (t.label) {
case 0:
return [ 4, this._request.send("database.startTransaction") ];

case 1:
if ((e = t.sent()).code) throw e;
return this.inited = !0, this._id = e.transactionId, [ 2 ];
}
});
});
}, e.prototype.collection = function(e) {
if (!e) throw new Error("Collection name is required");
return new st(this, e);
}, e.prototype.getTransactionId = function() {
return this._id;
}, e.prototype.getRequestMethod = function() {
return this._request;
}, e.prototype.commit = function() {
return at(this, void 0, void 0, function() {
var e, t;
return ut(this, function(n) {
switch (n.label) {
case 0:
return e = {
transactionId: this._id
}, [ 4, this._request.send("database.commitTransaction", e) ];

case 1:
if ((t = n.sent()).code) throw t;
return this.commited = !0, [ 2, t ];
}
});
});
}, e.prototype.rollback = function(e) {
return at(this, void 0, void 0, function() {
var t, n;
return ut(this, function(r) {
switch (r.label) {
case 0:
return t = {
transactionId: this._id
}, [ 4, this._request.send("database.abortTransaction", t) ];

case 1:
if ((n = r.sent()).code) throw n;
return this.aborted = !0, this.abortReason = e, [ 2, n ];
}
});
});
}, e;
}();
function ft() {
return at(this, void 0, void 0, function() {
var e;
return ut(this, function(t) {
switch (t.label) {
case 0:
return [ 4, (e = new ct(this)).init() ];

case 1:
return t.sent(), [ 2, e ];
}
});
});
}
function lt(e, t) {
return void 0 === t && (t = 3), at(this, void 0, void 0, function() {
var n, r, i, o, s = this;
return ut(this, function(a) {
switch (a.label) {
case 0:
return a.trys.push([ 0, 4, , 10 ]), [ 4, (n = new ct(this)).init() ];

case 1:
return a.sent(), [ 4, e(n) ];

case 2:
if (r = a.sent(), !0 === n.aborted) throw n.abortReason;
return [ 4, n.commit() ];

case 3:
return a.sent(), [ 2, r ];

case 4:
if (i = a.sent(), !1 === n.inited) throw i;
return o = function(e) {
return at(s, void 0, void 0, function() {
return ut(this, function(t) {
switch (t.label) {
case 0:
if (n.aborted || n.commited) return [ 3, 5 ];
t.label = 1;

case 1:
return t.trys.push([ 1, 3, , 4 ]), [ 4, n.rollback() ];

case 2:
case 3:
return t.sent(), [ 3, 4 ];

case 4:
throw e;

case 5:
if (!0 === n.aborted) throw n.abortReason;
throw e;
}
});
});
}, t <= 0 ? [ 4, o(i) ] : [ 3, 6 ];

case 5:
a.sent(), a.label = 6;

case 6:
return i && i.code === Ze.code ? [ 4, lt.bind(this)(e, --t) ] : [ 3, 8 ];

case 7:
return [ 2, a.sent() ];

case 8:
return [ 4, o(i) ];

case 9:
return a.sent(), [ 3, 10 ];

case 10:
return [ 2 ];
}
});
});
}
var ht = function() {
function e(e) {
this.config = e, this.Geo = o, this.serverDate = te, this.command = He, this.RegExp = Qe, 
this.startTransaction = ft, this.runTransaction = lt, this.logicCommand = le, this.updateCommand = ce, 
this.queryCommand = ye;
}
return e.prototype.collection = function(e) {
if (!e) throw new Error("Collection name is required");
return new Ye(this, e);
}, e.prototype.createCollection = function(t) {
var n = {
collectionName: t
};
return new e.reqClass(this.config).send("database.addCollection", n);
}, e;
}(), pt = function() {
return (pt = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}).apply(this, arguments);
}, dt = {
name: "database",
entity: {
database: function(e) {
var t = this.platform, n = t.adapter, r = t.runtime;
return ht.reqClass = this.request.constructor, ht.getAccessToken = this.authInstance ? this.authInstance.getAccessToken.bind(this.authInstance) : function() {
return "";
}, ht.runtime = r, this.wsClientClass && (ht.wsClass = n.wsClass, ht.wsClientClass = this.wsClientClass), 
ht.ws || (ht.ws = null), new ht(pt(pt({}, this.config), e));
}
}
};
try {
cloudbase.registerComponent(dt);
} catch (e) {}
function yt(e) {
try {
e.registerComponent(dt);
} catch (e) {
console.warn(e);
}
}
}, function(e, t, n) {
"use strict";
n.r(t), n.d(t, "registerRealtime", function() {
return $;
});
var r = n(12), i = n.n(r), o = n(13), s = n.n(o), a = n(14), u = n.n(a);
function c(e) {
return void 0 === e && (e = ""), (e ? e + "_" : "") + +new Date() + "_" + Math.random();
}
var f, l, h = function(e) {
this.close = e.close, this.onChange = e.onChange, this.onError = e.onError, e.debug && Object.defineProperty(this, "virtualClient", {
get: function() {
return e.virtualClient;
}
});
}, p = function(e) {
var t, n, r = e.id, i = e.docChanges, o = e.docs, s = e.msgType, a = e.type;
Object.defineProperties(this, {
id: {
get: function() {
return r;
},
enumerable: !0
},
docChanges: {
get: function() {
return t || (t = JSON.parse(JSON.stringify(i))), t;
},
enumerable: !0
},
docs: {
get: function() {
return n || (n = JSON.parse(JSON.stringify(o))), n;
},
enumerable: !0
},
msgType: {
get: function() {
return s;
},
enumerable: !0
},
type: {
get: function() {
return a;
},
enumerable: !0
}
});
}, d = (f = function(e, t) {
return (f = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
})(e, t);
}, function(e, t) {
function n() {
this.constructor = e;
}
f(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
new n());
}), y = function(e) {
function t(t) {
var n = e.call(this, "Watch Error " + JSON.stringify(t.msgData) + " (requestid: " + t.requestId + ")") || this;
return n.isRealtimeErrorMessageError = !0, n.payload = t, n;
}
return d(t, e), t;
}(Error), _ = function(e) {
return null == e ? void 0 : e.isRealtimeErrorMessageError;
}, g = function(e) {
function t() {
var t = null !== e && e.apply(this, arguments) || this;
return t.type = "timeout", t.payload = null, t.generic = !0, t;
}
return d(t, e), t;
}(Error), v = function(e) {
function t() {
var t = null !== e && e.apply(this, arguments) || this;
return t.type = "cancelled", t.payload = null, t.generic = !0, t;
}
return d(t, e), t;
}(Error), m = function(e) {
function t(t) {
var n = e.call(this, t.errMsg) || this;
return n.errCode = "UNKNOWN_ERROR", Object.defineProperties(n, {
message: {
get: function() {
return "errCode: " + this.errCode + " " + (b[this.errCode] || "") + " | errMsg: " + this.errMsg;
},
set: function(e) {
this.errMsg = e;
}
}
}), n.errCode = t.errCode || "UNKNOWN_ERROR", n.errMsg = t.errMsg, n;
}
return d(t, e), Object.defineProperty(t.prototype, "message", {
get: function() {
return "errCode: " + this.errCode + " | errMsg: " + this.errMsg;
},
set: function(e) {
this.errMsg = e;
},
enumerable: !1,
configurable: !0
}), t;
}(Error), b = {
UNKNOWN_ERROR: "UNKNOWN_ERROR",
SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL: "SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL",
SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL: "SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL",
SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL: "SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL",
SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL: "SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL",
SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG: "SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG",
SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA: "SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA",
SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR: "SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR",
SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED: "SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED",
SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL: "SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL",
SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR: "SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR"
}, w = function(e) {
return void 0 === e && (e = 0), new Promise(function(t) {
return setTimeout(t, e);
});
}, E = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, S = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, A = function() {
for (var e = 0, t = 0, n = arguments.length; t < n; t++) e += arguments[t].length;
var r = Array(e), i = 0;
for (t = 0; t < n; t++) for (var o = arguments[t], s = 0, a = o.length; s < a; s++, 
i++) r[i] = o[s];
return r;
};
!function(e) {
e.LOGGINGIN = "LOGGINGIN", e.INITING = "INITING", e.REBUILDING = "REBUILDING", e.ACTIVE = "ACTIVE", 
e.ERRORED = "ERRORED", e.CLOSING = "CLOSING", e.CLOSED = "CLOSED", e.PAUSED = "PAUSED", 
e.RESUMING = "RESUMING";
}(l || (l = {}));
var O = function() {
function e(e) {
var t = this;
this.watchStatus = l.INITING, this._login = function(e, n) {
return E(t, void 0, void 0, function() {
var t;
return S(this, function(r) {
switch (r.label) {
case 0:
return this.watchStatus = l.LOGGINGIN, [ 4, this.login(e, n) ];

case 1:
return t = r.sent(), this.envId || (this.envId = t.envId), [ 2, t ];
}
});
});
}, this.initWatch = function(e) {
return E(t, void 0, void 0, function() {
var t, n = this;
return S(this, function(r) {
switch (r.label) {
case 0:
if (this._initWatchPromise) return [ 2, this._initWatchPromise ];
this._initWatchPromise = new Promise(function(t, r) {
return E(n, void 0, void 0, function() {
var n, i, o, s, a, u, f, h, d, y;
return S(this, function(_) {
switch (_.label) {
case 0:
return _.trys.push([ 0, 3, , 4 ]), this.watchStatus === l.PAUSED ? (console.log("[realtime] initWatch cancelled on pause"), 
[ 2, t() ]) : [ 4, this._login(this.envId, e) ];

case 1:
return n = _.sent().envId, this.watchStatus === l.PAUSED ? (console.log("[realtime] initWatch cancelled on pause"), 
[ 2, t() ]) : (this.watchStatus = l.INITING, i = {
watchId: this.watchId,
requestId: c(),
msgType: "INIT_WATCH",
msgData: {
envId: n,
collName: this.collectionName,
query: this.query,
limit: this.limit,
orderBy: this.orderBy
}
}, [ 4, this.send({
msg: i,
waitResponse: !0,
skipOnMessage: !0,
timeout: 1e4
}) ]);

case 2:
if (o = _.sent(), s = o.msgData, a = s.events, u = s.currEvent, this.sessionInfo = {
queryID: o.msgData.queryID,
currentEventId: u - 1,
currentDocs: []
}, a.length > 0) {
for (f = 0, h = a; f < h.length; f++) h[f].ID = u;
this.handleServerEvents(o);
} else this.sessionInfo.currentEventId = u, d = new p({
id: u,
docChanges: [],
docs: [],
type: "init"
}), this.listener.onChange(d), this.scheduleSendACK();
return this.onWatchStart(this, this.sessionInfo.queryID), this.watchStatus = l.ACTIVE, 
this._availableRetries.INIT_WATCH = 2, t(), [ 3, 4 ];

case 3:
return y = _.sent(), this.handleWatchEstablishmentError(y, {
operationName: "INIT_WATCH",
resolve: t,
reject: r
}), [ 3, 4 ];

case 4:
return [ 2 ];
}
});
});
}), t = !1, r.label = 1;

case 1:
return r.trys.push([ 1, , 3, 4 ]), [ 4, this._initWatchPromise ];

case 2:
return r.sent(), t = !0, [ 3, 4 ];

case 3:
return this._initWatchPromise = void 0, [ 7 ];

case 4:
return console.log("[realtime] initWatch " + (t ? "success" : "fail")), [ 2 ];
}
});
});
}, this.rebuildWatch = function(e) {
return E(t, void 0, void 0, function() {
var t, n = this;
return S(this, function(r) {
switch (r.label) {
case 0:
if (this._rebuildWatchPromise) return [ 2, this._rebuildWatchPromise ];
this._rebuildWatchPromise = new Promise(function(t, r) {
return E(n, void 0, void 0, function() {
var n, i, o, s;
return S(this, function(a) {
switch (a.label) {
case 0:
return a.trys.push([ 0, 3, , 4 ]), this.watchStatus === l.PAUSED ? (console.log("[realtime] rebuildWatch cancelled on pause"), 
[ 2, t() ]) : [ 4, this._login(this.envId, e) ];

case 1:
if (n = a.sent().envId, !this.sessionInfo) throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");
return this.watchStatus === l.PAUSED ? (console.log("[realtime] rebuildWatch cancelled on pause"), 
[ 2, t() ]) : (this.watchStatus = l.REBUILDING, i = {
watchId: this.watchId,
requestId: c(),
msgType: "REBUILD_WATCH",
msgData: {
envId: n,
collName: this.collectionName,
queryID: this.sessionInfo.queryID,
eventID: this.sessionInfo.currentEventId
}
}, [ 4, this.send({
msg: i,
waitResponse: !0,
skipOnMessage: !1,
timeout: 1e4
}) ]);

case 2:
return o = a.sent(), this.handleServerEvents(o), this.watchStatus = l.ACTIVE, this._availableRetries.REBUILD_WATCH = 2, 
t(), [ 3, 4 ];

case 3:
return s = a.sent(), this.handleWatchEstablishmentError(s, {
operationName: "REBUILD_WATCH",
resolve: t,
reject: r
}), [ 3, 4 ];

case 4:
return [ 2 ];
}
});
});
}), t = !1, r.label = 1;

case 1:
return r.trys.push([ 1, , 3, 4 ]), [ 4, this._rebuildWatchPromise ];

case 2:
return r.sent(), t = !0, [ 3, 4 ];

case 3:
return this._rebuildWatchPromise = void 0, [ 7 ];

case 4:
return console.log("[realtime] rebuildWatch " + (t ? "success" : "fail")), [ 2 ];
}
});
});
}, this.handleWatchEstablishmentError = function(e, n) {
return E(t, void 0, void 0, function() {
var t, r, i, o = this;
return S(this, function() {
return t = "INIT_WATCH" === n.operationName, r = function() {
o.closeWithError(new m({
errCode: t ? b.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL : b.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,
errMsg: e
})), n.reject(e);
}, i = function(e) {
o.useRetryTicket(n.operationName) ? t ? (o._initWatchPromise = void 0, n.resolve(o.initWatch(e))) : (o._rebuildWatchPromise = void 0, 
n.resolve(o.rebuildWatch(e))) : r();
}, this.handleCommonError(e, {
onSignError: function() {
return i(!0);
},
onTimeoutError: function() {
return i(!1);
},
onNotRetryableError: r,
onCancelledError: n.reject,
onUnknownError: function() {
return E(o, void 0, void 0, function() {
var e, t = this;
return S(this, function(r) {
switch (r.label) {
case 0:
return r.trys.push([ 0, 8, , 9 ]), e = function() {
return E(t, void 0, void 0, function() {
return S(this, function(e) {
switch (e.label) {
case 0:
return this.pause(), [ 4, this.onceWSConnected() ];

case 1:
return e.sent(), i(!0), [ 2 ];
}
});
});
}, this.isWSConnected() ? [ 3, 2 ] : [ 4, e() ];

case 1:
return r.sent(), [ 3, 7 ];

case 2:
return [ 4, w(100) ];

case 3:
return r.sent(), this.watchStatus !== l.PAUSED ? [ 3, 4 ] : (n.reject(new v(n.operationName + " cancelled due to pause after unknownError")), 
[ 3, 7 ]);

case 4:
return this.isWSConnected() ? [ 3, 6 ] : [ 4, e() ];

case 5:
return r.sent(), [ 3, 7 ];

case 6:
i(!1), r.label = 7;

case 7:
return [ 3, 9 ];

case 8:
return r.sent(), i(!0), [ 3, 9 ];

case 9:
return [ 2 ];
}
});
});
}
}), [ 2 ];
});
});
}, this.closeWatch = function() {
return E(t, void 0, void 0, function() {
var e, t, n;
return S(this, function(r) {
switch (r.label) {
case 0:
if (e = this.sessionInfo ? this.sessionInfo.queryID : "", this.watchStatus !== l.ACTIVE) return this.watchStatus = l.CLOSED, 
this.onWatchClose(this, e), [ 2 ];
r.label = 1;

case 1:
return r.trys.push([ 1, 3, 4, 5 ]), this.watchStatus = l.CLOSING, t = {
watchId: this.watchId,
requestId: c(),
msgType: "CLOSE_WATCH",
msgData: null
}, [ 4, this.send({
msg: t
}) ];

case 2:
return r.sent(), this.sessionInfo = void 0, this.watchStatus = l.CLOSED, [ 3, 5 ];

case 3:
return n = r.sent(), this.closeWithError(new m({
errCode: b.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,
errMsg: n
})), [ 3, 5 ];

case 4:
return this.onWatchClose(this, e), [ 7 ];

case 5:
return [ 2 ];
}
});
});
}, this.scheduleSendACK = function() {
t.clearACKSchedule(), t._ackTimeoutId = setTimeout(function() {
t._waitExpectedTimeoutId ? t.scheduleSendACK() : t.sendACK();
}, 1e4);
}, this.clearACKSchedule = function() {
t._ackTimeoutId && clearTimeout(t._ackTimeoutId);
}, this.sendACK = function() {
return E(t, void 0, void 0, function() {
var e, t, n;
return S(this, function(r) {
switch (r.label) {
case 0:
return r.trys.push([ 0, 2, , 3 ]), this.watchStatus !== l.ACTIVE ? (this.scheduleSendACK(), 
[ 2 ]) : this.sessionInfo ? (e = {
watchId: this.watchId,
requestId: c(),
msgType: "CHECK_LAST",
msgData: {
queryID: this.sessionInfo.queryID,
eventID: this.sessionInfo.currentEventId
}
}, [ 4, this.send({
msg: e
}) ]) : (console.warn("[realtime listener] can not send ack without a successful initWatch (lack of sessionInfo)"), 
[ 2 ]);

case 1:
return r.sent(), this.scheduleSendACK(), [ 3, 3 ];

case 2:
if (t = r.sent(), _(t)) switch ((n = t.payload).msgData.code) {
case "CHECK_LOGIN_FAILED":
case "SIGN_EXPIRED_ERROR":
case "SIGN_INVALID_ERROR":
case "SIGN_PARAM_INVALID":
return this.rebuildWatch(), [ 2 ];

case "QUERYID_INVALID_ERROR":
case "SYS_ERR":
case "INVALIID_ENV":
case "COLLECTION_PERMISSION_DENIED":
return this.closeWithError(new m({
errCode: b.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,
errMsg: n.msgData.code
})), [ 2 ];
}
return this._availableRetries.CHECK_LAST && this._availableRetries.CHECK_LAST > 0 ? (this._availableRetries.CHECK_LAST--, 
this.scheduleSendACK()) : this.closeWithError(new m({
errCode: b.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,
errMsg: t
})), [ 3, 3 ];

case 3:
return [ 2 ];
}
});
});
}, this.handleCommonError = function(e, t) {
if (_(e)) switch (e.payload.msgData.code) {
case "CHECK_LOGIN_FAILED":
case "SIGN_EXPIRED_ERROR":
case "SIGN_INVALID_ERROR":
case "SIGN_PARAM_INVALID":
return void t.onSignError(e);

case "QUERYID_INVALID_ERROR":
case "SYS_ERR":
case "INVALIID_ENV":
case "COLLECTION_PERMISSION_DENIED":
default:
return void t.onNotRetryableError(e);
} else {
if (function(e) {
return "timeout" === e.type;
}(e)) return void t.onTimeoutError(e);
if (function(e) {
return "cancelled" === e.type;
}(e)) return void t.onCancelledError(e);
}
t.onUnknownError(e);
}, this.watchId = "watchid_" + +new Date() + "_" + Math.random(), this.envId = e.envId, 
this.collectionName = e.collectionName, this.query = e.query, this.limit = e.limit, 
this.orderBy = e.orderBy, this.send = e.send, this.login = e.login, this.isWSConnected = e.isWSConnected, 
this.onceWSConnected = e.onceWSConnected, this.getWaitExpectedTimeoutLength = e.getWaitExpectedTimeoutLength, 
this.onWatchStart = e.onWatchStart, this.onWatchClose = e.onWatchClose, this.debug = e.debug, 
this._availableRetries = {
INIT_WATCH: 2,
REBUILD_WATCH: 2,
CHECK_LAST: 2
}, this.listener = new h({
close: this.closeWatch,
onChange: e.onChange,
onError: e.onError,
debug: this.debug,
virtualClient: this
}), this.initWatch();
}
return e.prototype.onMessage = function(e) {
var t = this;
switch (this.watchStatus) {
case l.PAUSED:
if ("ERROR" !== e.msgType) return;
break;

case l.LOGGINGIN:
case l.INITING:
case l.REBUILDING:
return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while " + this.watchStatus);

case l.CLOSED:
return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");

case l.ERRORED:
return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has ended with error");
}
if (this.sessionInfo) switch (this.scheduleSendACK(), e.msgType) {
case "NEXT_EVENT":
console.warn("nextevent " + e.msgData.currEvent + " ignored", e), this.handleServerEvents(e);
break;

case "CHECK_EVENT":
this.sessionInfo.currentEventId < e.msgData.currEvent && (this.sessionInfo.expectEventId = e.msgData.currEvent, 
this.clearWaitExpectedEvent(), this._waitExpectedTimeoutId = setTimeout(function() {
t.rebuildWatch();
}, this.getWaitExpectedTimeoutLength()), console.log("[realtime] waitExpectedTimeoutLength " + this.getWaitExpectedTimeoutLength()));
break;

case "ERROR":
this.closeWithError(new m({
errCode: b.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,
errMsg: e.msgData.code + " - " + e.msgData.message
}));
break;

default:
console.warn("[realtime listener] virtual client receive unexpected msg " + e.msgType + ": ", e);
} else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.");
}, e.prototype.closeWithError = function(e) {
this.watchStatus = l.ERRORED, this.clearACKSchedule(), this.listener.onError(e), 
this.onWatchClose(this, this.sessionInfo && this.sessionInfo.queryID || ""), console.log("[realtime] client closed (" + this.collectionName + " " + this.query + ") (watchId " + this.watchId + ")");
}, e.prototype.pause = function() {
this.watchStatus = l.PAUSED, console.log("[realtime] client paused (" + this.collectionName + " " + this.query + ") (watchId " + this.watchId + ")");
}, e.prototype.resume = function() {
return E(this, void 0, void 0, function() {
var e;
return S(this, function(t) {
switch (t.label) {
case 0:
this.watchStatus = l.RESUMING, console.log("[realtime] client resuming with " + (this.sessionInfo ? "REBUILD_WATCH" : "INIT_WATCH") + " (" + this.collectionName + " " + this.query + ") (" + this.watchId + ")"), 
t.label = 1;

case 1:
return t.trys.push([ 1, 3, , 4 ]), [ 4, this.sessionInfo ? this.rebuildWatch() : this.initWatch() ];

case 2:
return t.sent(), console.log("[realtime] client successfully resumed (" + this.collectionName + " " + this.query + ") (" + this.watchId + ")"), 
[ 3, 4 ];

case 3:
return e = t.sent(), console.error("[realtime] client resume failed (" + this.collectionName + " " + this.query + ") (" + this.watchId + ")", e), 
[ 3, 4 ];

case 4:
return [ 2 ];
}
});
});
}, e.prototype.useRetryTicket = function(e) {
return !!(this._availableRetries[e] && this._availableRetries[e] > 0) && (this._availableRetries[e]--, 
console.log("[realtime] " + e + " use a retry ticket, now only " + this._availableRetries[e] + " retry left"), 
!0);
}, e.prototype.handleServerEvents = function(e) {
return E(this, void 0, void 0, function() {
var t;
return S(this, function(n) {
switch (n.label) {
case 0:
return n.trys.push([ 0, 2, , 3 ]), this.scheduleSendACK(), [ 4, this._handleServerEvents(e) ];

case 1:
return n.sent(), this._postHandleServerEventsValidityCheck(e), [ 3, 3 ];

case 2:
throw t = n.sent(), console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ", t), 
t;

case 3:
return [ 2 ];
}
});
});
}, e.prototype._handleServerEvents = function(e) {
return E(this, void 0, void 0, function() {
var t, n, r, o, a, c, f, l, h, d, y, _;
return S(this, function(g) {
switch (g.label) {
case 0:
if (t = e.requestId, n = e.msgData.events, r = e.msgType, !n.length || !this.sessionInfo) return [ 2 ];
o = this.sessionInfo;
try {
a = n.map(I);
} catch (e) {
return this.closeWithError(new m({
errCode: b.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,
errMsg: e
})), [ 2 ];
}
c = A(o.currentDocs), f = !1, l = function(n, l) {
var d, y, _, g, v, w, E, O, I, T, N;
return S(this, function(S) {
switch (S.label) {
case 0:
return d = a[n], o.currentEventId >= d.id ? (!a[n - 1] || d.id > a[n - 1].id ? console.warn("[realtime] duplicate event received, cur " + o.currentEventId + " but got " + d.id) : console.error("[realtime listener] server non-fatal error: events out of order (the latter event's id is smaller than that of the former) (requestId " + t + ")"), 
[ 2, "continue" ]) : [ 3, 1 ];

case 1:
if (o.currentEventId !== d.id - 1) return [ 3, 2 ];
switch (d.dataType) {
case "update":
if (!d.doc) switch (d.queueType) {
case "update":
case "dequeue":
if (y = c.find(function(e) {
return e._id === d.docId;
})) {
if (w = u()(y), d.updatedFields) for (v in d.updatedFields) i()(w, v, d.updatedFields[v]);
if (d.removedFields) for (_ = 0, g = d.removedFields; _ < g.length; _++) v = g[_], 
s()(w, v);
d.doc = w;
} else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");
break;

case "enqueue":
throw E = new m({
errCode: b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,
errMsg: 'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId ' + e.requestId + ")"
}), h.closeWithError(E), E;
}
break;

case "replace":
if (!d.doc) throw E = new m({
errCode: b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,
errMsg: 'HandleServerEvents: full doc is not provided with dataType="replace" (requestId ' + e.requestId + ")"
}), h.closeWithError(E), E;
break;

case "remove":
(w = c.find(function(e) {
return e._id === d.docId;
})) ? d.doc = w : console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");
break;

case "limit":
if (!d.doc) switch (d.queueType) {
case "dequeue":
(w = c.find(function(e) {
return e._id === d.docId;
})) ? d.doc = w : console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");
break;

case "enqueue":
throw E = new m({
errCode: b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,
errMsg: 'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId ' + e.requestId + ")"
}), h.closeWithError(E), E;
}
}
switch (d.queueType) {
case "init":
f ? c.push(d.doc) : (f = !0, c = [ d.doc ]);
break;

case "enqueue":
c.push(d.doc);
break;

case "dequeue":
(O = c.findIndex(function(e) {
return e._id === d.docId;
})) > -1 ? c.splice(O, 1) : console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");
break;

case "update":
(O = c.findIndex(function(e) {
return e._id === d.docId;
})) > -1 ? c[O] = d.doc : console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.");
}
return (n === l - 1 || a[n + 1] && a[n + 1].id !== d.id) && (I = A(c), T = a.slice(0, n + 1).filter(function(e) {
return e.id === d.id;
}), h.sessionInfo.currentEventId = d.id, h.sessionInfo.currentDocs = c, N = new p({
id: d.id,
docChanges: T,
docs: I,
msgType: r
}), h.listener.onChange(N)), [ 3, 4 ];

case 2:
return console.warn("[realtime listener] event received is out of order, cur " + h.sessionInfo.currentEventId + " but got " + d.id), 
[ 4, h.rebuildWatch() ];

case 3:
return S.sent(), [ 2, {
value: void 0
} ];

case 4:
return [ 2 ];
}
});
}, h = this, d = 0, y = a.length, g.label = 1;

case 1:
return d < y ? [ 5, l(d, y) ] : [ 3, 4 ];

case 2:
if ("object" == typeof (_ = g.sent())) return [ 2, _.value ];
g.label = 3;

case 3:
return d++, [ 3, 1 ];

case 4:
return [ 2 ];
}
});
});
}, e.prototype._postHandleServerEventsValidityCheck = function(e) {
this.sessionInfo ? (this.sessionInfo.expectEventId && this.sessionInfo.currentEventId >= this.sessionInfo.expectEventId && this.clearWaitExpectedEvent(), 
this.sessionInfo.currentEventId < e.msgData.currEvent && console.warn("[realtime listener] internal non-fatal error: client eventId does not match with server event id after server event handling")) : console.error("[realtime listener] internal non-fatal error: sessionInfo lost after server event handling, this should never occur");
}, e.prototype.clearWaitExpectedEvent = function() {
this._waitExpectedTimeoutId && (clearTimeout(this._waitExpectedTimeoutId), this._waitExpectedTimeoutId = void 0);
}, e;
}();
function I(e) {
var t = {
id: e.ID,
dataType: e.DataType,
queueType: e.QueueType,
docId: e.DocID,
doc: e.Doc && "{}" !== e.Doc ? JSON.parse(e.Doc) : void 0
};
return "update" === e.DataType && (e.UpdatedFields && (t.updatedFields = JSON.parse(e.UpdatedFields)), 
(e.removedFields || e.RemovedFields) && (t.removedFields = JSON.parse(e.removedFields))), 
t;
}
var T, N = {
1e3: {
code: 1e3,
name: "Normal Closure",
description: "Normal closure; the connection successfully completed whatever purpose for which it was created."
},
1001: {
code: 1001,
name: "Going Away",
description: "The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."
},
1002: {
code: 1002,
name: "Protocol Error",
description: "The endpoint is terminating the connection due to a protocol error."
},
1003: {
code: 1003,
name: "Unsupported Data",
description: "The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data)."
},
1005: {
code: 1005,
name: "No Status Received",
description: "Indicates that no status code was provided even though one was expected."
},
1006: {
code: 1006,
name: "Abnormal Closure",
description: "Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."
},
1007: {
code: 1007,
name: "Invalid frame payload data",
description: "The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."
},
1008: {
code: 1008,
name: "Policy Violation",
description: "The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."
},
1009: {
code: 1009,
name: "Message too big",
description: "The endpoint is terminating the connection because a data frame was received that is too large."
},
1010: {
code: 1010,
name: "Missing Extension",
description: "The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."
},
1011: {
code: 1011,
name: "Internal Error",
description: "The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."
},
1012: {
code: 1012,
name: "Service Restart",
description: "The server is terminating the connection because it is restarting."
},
1013: {
code: 1013,
name: "Try Again Later",
description: "The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."
},
1014: {
code: 1014,
name: "Bad Gateway",
description: "The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."
},
1015: {
code: 1015,
name: "TLS Handshake",
description: "Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."
},
3e3: {
code: 3e3,
name: "Reconnect WebSocket",
description: "The client is terminating the connection because it wants to reconnect"
},
3001: {
code: 3001,
name: "No Realtime Listeners",
description: "The client is terminating the connection because no more realtime listeners exist"
},
3002: {
code: 3002,
name: "Heartbeat Ping Error",
description: "The client is terminating the connection due to its failure in sending heartbeat messages"
},
3003: {
code: 3003,
name: "Heartbeat Pong Timeout Error",
description: "The client is terminating the connection because no heartbeat response is received from the server"
},
3050: {
code: 3050,
name: "Server Close",
description: "The client is terminating the connection because no heartbeat response is received from the server"
}
};
!function(e) {
e[e.NormalClosure = 1e3] = "NormalClosure", e[e.GoingAway = 1001] = "GoingAway", 
e[e.ProtocolError = 1002] = "ProtocolError", e[e.UnsupportedData = 1003] = "UnsupportedData", 
e[e.NoStatusReceived = 1005] = "NoStatusReceived", e[e.AbnormalClosure = 1006] = "AbnormalClosure", 
e[e.InvalidFramePayloadData = 1007] = "InvalidFramePayloadData", e[e.PolicyViolation = 1008] = "PolicyViolation", 
e[e.MessageTooBig = 1009] = "MessageTooBig", e[e.MissingExtension = 1010] = "MissingExtension", 
e[e.InternalError = 1011] = "InternalError", e[e.ServiceRestart = 1012] = "ServiceRestart", 
e[e.TryAgainLater = 1013] = "TryAgainLater", e[e.BadGateway = 1014] = "BadGateway", 
e[e.TLSHandshake = 1015] = "TLSHandshake", e[e.ReconnectWebSocket = 3e3] = "ReconnectWebSocket", 
e[e.NoRealtimeListeners = 3001] = "NoRealtimeListeners", e[e.HeartbeatPingError = 3002] = "HeartbeatPingError", 
e[e.HeartbeatPongTimeoutError = 3003] = "HeartbeatPongTimeoutError", e[e.NoAuthentication = 3050] = "NoAuthentication";
}(T || (T = {}));
var R = function(e, t) {
var n = N[e], r = n ? n.name + ", code " + e + ", reason " + (t || n.description) : "code " + e;
return new m({
errCode: b.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,
errMsg: r
});
}, P = null, B = "web";
function D() {
return B;
}
var C = function() {
return (C = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}).apply(this, arguments);
}, L = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, x = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, k = 1, U = function() {
function e(e) {
var t = this;
this._virtualWSClient = new Set(), this._queryIdClientMap = new Map(), this._watchIdClientMap = new Map(), 
this._pingFailed = 0, this._pongMissed = 0, this._logins = new Map(), this._wsReadySubsribers = [], 
this._wsResponseWait = new Map(), this._rttObserved = [], this.send = function(e) {
return L(t, void 0, void 0, function() {
var t = this;
return x(this, function() {
return [ 2, new Promise(function(n, r) {
return L(t, void 0, void 0, function() {
var t, i, o, s, a, u, c, f = this;
return x(this, function(l) {
switch (l.label) {
case 0:
i = !1, o = !1, s = function(e) {
i = !0, t && clearTimeout(t), n(e);
}, a = function(e) {
o = !0, t && clearTimeout(t), r(e);
}, e.timeout && (t = setTimeout(function() {
return L(f, void 0, void 0, function() {
return x(this, function(e) {
switch (e.label) {
case 0:
return i && o ? [ 3, 2 ] : [ 4, w(0) ];

case 1:
e.sent(), i && o || a(new g("wsclient.send timedout")), e.label = 2;

case 2:
return [ 2 ];
}
});
});
}, e.timeout)), l.label = 1;

case 1:
return l.trys.push([ 1, 8, , 9 ]), this._wsInitPromise ? [ 4, this._wsInitPromise ] : [ 3, 3 ];

case 2:
l.sent(), l.label = 3;

case 3:
if (!this._ws) return a(new Error("invalid state: ws connection not exists, can not send message")), 
[ 2 ];
if (this._ws.readyState !== k) return a(new Error("ws readyState invalid: " + this._ws.readyState + ", can not send message")), 
[ 2 ];
e.waitResponse && this._wsResponseWait.set(e.msg.requestId, {
resolve: s,
reject: a,
skipOnMessage: e.skipOnMessage
}), l.label = 4;

case 4:
return l.trys.push([ 4, 6, , 7 ]), [ 4, this._ws.send(JSON.stringify(e.msg)) ];

case 5:
return l.sent(), e.waitResponse || s(), [ 3, 7 ];

case 6:
return (u = l.sent()) && (a(u), e.waitResponse && this._wsResponseWait.delete(e.msg.requestId)), 
[ 3, 7 ];

case 7:
return [ 3, 9 ];

case 8:
return c = l.sent(), a(c), [ 3, 9 ];

case 9:
return [ 2 ];
}
});
});
}) ];
});
});
}, this.closeAllClients = function(e) {
t._virtualWSClient.forEach(function(t) {
t.closeWithError(e);
});
}, this.pauseClients = function(e) {
(e || t._virtualWSClient).forEach(function(e) {
e.pause();
});
}, this.resumeClients = function(e) {
(e || t._virtualWSClient).forEach(function(e) {
e.resume();
});
}, this.initWebSocketConnection = function(e, n) {
return void 0 === n && (n = t._maxReconnect), L(t, void 0, void 0, function() {
var t = this;
return x(this, function(r) {
switch (r.label) {
case 0:
if (e && this._reconnectState) return [ 2 ];
if (e && (this._reconnectState = !0), this._wsInitPromise) return [ 2, this._wsInitPromise ];
e && this.pauseClients(), this.close(T.ReconnectWebSocket), this._wsInitPromise = new Promise(function(r, i) {
return L(t, void 0, void 0, function() {
var t, o, s = this;
return x(this, function(a) {
switch (a.label) {
case 0:
return a.trys.push([ 0, 6, , 11 ]), [ 4, this.getWsSign() ];

case 1:
return t = a.sent(), [ 4, new Promise(function(e) {
var n = t.wsUrl || "wss://tcb-ws.tencentcloudapi.com", r = P;
s._ws = r ? new r(n) : new WebSocket(n), e();
}) ];

case 2:
return a.sent(), this._ws.connect ? [ 4, this._ws.connect() ] : [ 3, 4 ];

case 3:
a.sent(), a.label = 4;

case 4:
return [ 4, this.initWebSocketEvent() ];

case 5:
return a.sent(), r(), e && (this.resumeClients(), this._reconnectState = !1), [ 3, 11 ];

case 6:
return o = a.sent(), console.error("[realtime] initWebSocketConnection connect fail", o), 
n > 0 ? (this._wsInitPromise = void 0, [ 4, w(this._reconnectInterval) ]) : [ 3, 9 ];

case 7:
a.sent(), e && (this._reconnectState = !1), a.label = 8;

case 8:
return r(this.initWebSocketConnection(e, n - 1)), [ 3, 10 ];

case 9:
i(o), e && this.closeAllClients(new m({
errCode: b.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,
errMsg: o
})), a.label = 10;

case 10:
return [ 3, 11 ];

case 11:
return [ 2 ];
}
});
});
}), r.label = 1;

case 1:
return r.trys.push([ 1, 3, 4, 5 ]), [ 4, this._wsInitPromise ];

case 2:
return r.sent(), this._wsReadySubsribers.forEach(function(e) {
return (0, e.resolve)();
}), [ 3, 5 ];

case 3:
return r.sent(), this._wsReadySubsribers.forEach(function(e) {
return (0, e.reject)();
}), [ 3, 5 ];

case 4:
return this._wsInitPromise = void 0, this._wsReadySubsribers = [], [ 7 ];

case 5:
return [ 2 ];
}
});
});
}, this.initWebSocketEvent = function() {
return new Promise(function(e, n) {
if (!t._ws) throw new Error("can not initWebSocketEvent, ws not exists");
var r = !1;
t._ws.onopen = function(t) {
console.warn("[realtime] ws event: open", t), r = !0, e();
}, t._ws.onerror = function(e) {
t._logins = new Map(), r ? (console.error("[realtime] ws event: error", e), t.clearHeartbeat(), 
t._virtualWSClient.forEach(function(t) {
return t.closeWithError(new m({
errCode: b.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,
errMsg: e
}));
})) : (console.error("[realtime] ws open failed with ws event: error", e), n(e));
}, t._ws.onclose = function(e) {
switch (console.warn("[realtime] ws event: close", e), t._logins = new Map(), t.clearHeartbeat(), 
e.code) {
case T.ReconnectWebSocket:
case T.NoRealtimeListeners:
break;

case T.HeartbeatPingError:
case T.HeartbeatPongTimeoutError:
case T.NormalClosure:
case T.AbnormalClosure:
t._maxReconnect > 0 ? t.initWebSocketConnection(!0, t._maxReconnect) : t.closeAllClients(R(e.code));
break;

case T.NoAuthentication:
t.closeAllClients(R(e.code, e.reason));
break;

default:
t._maxReconnect > 0 ? t.initWebSocketConnection(!0, t._maxReconnect) : t.closeAllClients(R(e.code));
}
}, t._ws.onmessage = function(e) {
var n, r = e.data;
t.heartbeat();
try {
n = JSON.parse(r);
} catch (e) {
throw new Error("[realtime] onMessage parse res.data error: " + e);
}
if ("ERROR" === n.msgType) {
var i = null;
t._virtualWSClient.forEach(function(e) {
e.watchId === n.watchId && (i = e);
}), i && i.listener.onError(n);
}
var o = t._wsResponseWait.get(n.requestId);
if (o) {
try {
"ERROR" === n.msgType ? o.reject(new y(n)) : o.resolve(n);
} catch (e) {
console.error("ws onMessage responseWaitSpec.resolve(msg) errored:", e);
} finally {
t._wsResponseWait.delete(n.requestId);
}
if (o.skipOnMessage) return;
}
if ("PONG" !== n.msgType) {
var s = n.watchId && t._watchIdClientMap.get(n.watchId);
if (s) s.onMessage(n); else switch (console.error("[realtime] no realtime listener found responsible for watchId " + n.watchId + ": ", n), 
n.msgType) {
case "INIT_EVENT":
case "NEXT_EVENT":
case "CHECK_EVENT":
(s = t._queryIdClientMap.get(n.msgData.queryID)) && s.onMessage(n);
break;

default:
for (var a = 0, u = Array.from(t._watchIdClientMap.entries()); a < u.length; a++) {
u[a][1].onMessage(n);
break;
}
}
} else if (t._lastPingSendTS) {
var c = Date.now() - t._lastPingSendTS;
if (c > 1e4) return void console.warn("[realtime] untrusted rtt observed: " + c);
t._rttObserved.length >= 3 && t._rttObserved.splice(0, t._rttObserved.length - 3 + 1), 
t._rttObserved.push(c);
}
}, t.heartbeat();
});
}, this.isWSConnected = function() {
return Boolean(t._ws && t._ws.readyState === k);
}, this.onceWSConnected = function() {
return L(t, void 0, void 0, function() {
var e = this;
return x(this, function() {
return this.isWSConnected() ? [ 2 ] : this._wsInitPromise ? [ 2, this._wsInitPromise ] : [ 2, new Promise(function(t, n) {
e._wsReadySubsribers.push({
resolve: t,
reject: n
});
}) ];
});
});
}, this.webLogin = function(e, n) {
return L(t, void 0, void 0, function() {
var t, r, i, o, s, a, u, f, l = this;
return x(this, function(h) {
switch (h.label) {
case 0:
if (!n) if (e) {
if (t = this._logins.get(e)) {
if (t.loggedIn && t.loginResult) return [ 2, t.loginResult ];
if (t.loggingInPromise) return [ 2, t.loggingInPromise ];
}
} else if (null == (r = this._logins.get("")) ? void 0 : r.loggingInPromise) return [ 2, r.loggingInPromise ];
i = new Promise(function(e, t) {
return L(l, void 0, void 0, function() {
var n, r, i, o, s;
return x(this, function(a) {
switch (a.label) {
case 0:
return a.trys.push([ 0, 3, , 4 ]), [ 4, this.getWsSign() ];

case 1:
return n = a.sent(), r = {
envId: n.envId || "",
accessToken: "",
referrer: "web",
sdkVersion: "",
dataVersion: ""
}, i = {
watchId: void 0,
requestId: c(),
msgType: "LOGIN",
msgData: r,
exMsgData: {
runtime: D(),
signStr: n.signStr,
secretVersion: n.secretVersion
}
}, [ 4, this.send({
msg: i,
waitResponse: !0,
skipOnMessage: !0,
timeout: 5e3
}) ];

case 2:
return (o = a.sent()).msgData.code ? t(new Error(o.msgData.code + " " + o.msgData.message)) : e({
envId: n.envId
}), [ 3, 4 ];

case 3:
return s = a.sent(), t(s), [ 3, 4 ];

case 4:
return [ 2 ];
}
});
});
}), o = e && this._logins.get(e), s = Date.now(), o ? (o.loggedIn = !1, o.loggingInPromise = i, 
o.loginStartTS = s) : (o = {
loggedIn: !1,
loggingInPromise: i,
loginStartTS: s
}, this._logins.set(e || "", o)), h.label = 1;

case 1:
return h.trys.push([ 1, 3, , 4 ]), [ 4, i ];

case 2:
if (a = h.sent(), (u = e && this._logins.get(e)) && u === o && u.loginStartTS === s) return o.loggedIn = !0, 
o.loggingInPromise = void 0, o.loginStartTS = void 0, o.loginResult = a, [ 2, a ];
if (u) {
if (u.loggedIn && u.loginResult) return [ 2, u.loginResult ];
if (u.loggingInPromise) return [ 2, u.loggingInPromise ];
throw new Error("ws unexpected login info");
}
throw new Error("ws login info reset");

case 3:
throw f = h.sent(), o.loggedIn = !1, o.loggingInPromise = void 0, o.loginStartTS = void 0, 
o.loginResult = void 0, f;

case 4:
return [ 2 ];
}
});
});
}, this.getWsSign = function() {
return L(t, void 0, void 0, function() {
var e, t, n, r, i, o, s;
return x(this, function(a) {
switch (a.label) {
case 0:
return this._wsSign && this._wsSign.expiredTs > Date.now() ? [ 2, this._wsSign ] : (e = Date.now() + 6e4, 
[ 4, this._context.appConfig.request.send("auth.wsWebSign", {
runtime: D()
}) ]);

case 1:
if ((t = a.sent()).code) throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: " + t.code);
if (t.data) return n = t.data, r = n.signStr, i = n.wsUrl, o = n.secretVersion, 
s = n.envId, [ 2, {
signStr: r,
wsUrl: i,
secretVersion: o,
envId: s,
expiredTs: e
} ];
throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败");
}
});
});
}, this.getWaitExpectedTimeoutLength = function() {
return t._rttObserved.length ? t._rttObserved.reduce(function(e, t) {
return e + t;
}) / t._rttObserved.length * 1.5 : 5e3;
}, this.ping = function() {
return L(t, void 0, void 0, function() {
var e;
return x(this, function(t) {
switch (t.label) {
case 0:
return e = {
watchId: void 0,
requestId: c(),
msgType: "PING",
msgData: null
}, [ 4, this.send({
msg: e
}) ];

case 1:
return t.sent(), [ 2 ];
}
});
});
}, this.onWatchStart = function(e, n) {
t._queryIdClientMap.set(n, e);
}, this.onWatchClose = function(e, n) {
n && t._queryIdClientMap.delete(n), t._watchIdClientMap.delete(e.watchId), t._virtualWSClient.delete(e), 
t._virtualWSClient.size || t.close(T.NoRealtimeListeners);
}, this._maxReconnect = e.maxReconnect || 5, this._reconnectInterval = e.reconnectInterval || 1e4, 
this._context = e.context;
}
return e.prototype.clearHeartbeat = function() {
this._pingTimeoutId && clearTimeout(this._pingTimeoutId), this._pongTimeoutId && clearTimeout(this._pongTimeoutId);
}, e.prototype.close = function(e) {
this.clearHeartbeat(), this._ws && (this._ws.close(e, N[e].name), this._ws = void 0);
}, e.prototype.watch = function(e) {
this._ws || this._wsInitPromise || this.initWebSocketConnection(!1);
var t = new O(C(C({}, e), {
send: this.send,
login: this.webLogin,
isWSConnected: this.isWSConnected,
onceWSConnected: this.onceWSConnected,
getWaitExpectedTimeoutLength: this.getWaitExpectedTimeoutLength,
onWatchStart: this.onWatchStart,
onWatchClose: this.onWatchClose,
debug: !0
}));
return this._virtualWSClient.add(t), this._watchIdClientMap.set(t.watchId, t), t.listener;
}, e.prototype.heartbeat = function(e) {
var t = this;
this.clearHeartbeat(), this._pingTimeoutId = setTimeout(function() {
return L(t, void 0, void 0, function() {
var e = this;
return x(this, function(t) {
switch (t.label) {
case 0:
return t.trys.push([ 0, 2, , 3 ]), this._ws && this._ws.readyState === k ? (this._lastPingSendTS = Date.now(), 
[ 4, this.ping() ]) : [ 2 ];

case 1:
return t.sent(), this._pingFailed = 0, this._pongTimeoutId = setTimeout(function() {
console.error("pong timed out"), e._pongMissed < 2 ? (e._pongMissed++, e.heartbeat(!0)) : e.initWebSocketConnection(!0);
}, this._context.appConfig.realtimePongWaitTimeout), [ 3, 3 ];

case 2:
return t.sent(), this._pingFailed < 2 ? (this._pingFailed++, this.heartbeat()) : this.close(T.HeartbeatPingError), 
[ 3, 3 ];

case 3:
return [ 2 ];
}
});
});
}, e ? 0 : this._context.appConfig.realtimePingInterval);
}, e;
}(), M = {
target: "database",
entity: function() {
var e, t = this.platform, n = t.adapter, r = t.runtime;
e = n.wsClass, P = e, B = r;
}
}, j = {
name: "realtime",
IIFE: !0,
entity: function() {
this.prototype.wsClientClass = U;
}
};
try {
cloudbase.registerComponent(j), cloudbase.registerHook(M);
} catch (e) {}
function $(e) {
try {
e.registerComponent(j), e.registerHook(M);
} catch (e) {
console.warn(e);
}
}
}, function(e, t, n) {
"use strict";
n.r(t), n.d(t, "LoginState", function() {
return Ne;
}), n.d(t, "Auth", function() {
return Re;
}), n.d(t, "AuthProvider", function() {
return a;
}), n.d(t, "EVENTS", function() {
return Pe;
}), n.d(t, "eventBus", function() {
return Ie;
}), n.d(t, "registerAuth", function() {
return De;
}), n.d(t, "registerProvider", function() {
return Ce;
});
var r, i = n(0), o = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, s = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, a = function() {
function e(e) {
this._config = e, this._cache = e.cache, this._request = e.request;
}
return e.prototype.checkLocalLoginState = function() {
return o(this, void 0, void 0, function() {
var e, t, n, r, i, o;
return s(this, function(s) {
switch (s.label) {
case 0:
return e = this._cache.keys, t = e.accessTokenKey, n = e.accessTokenExpireKey, [ 4, this._cache.getStoreAsync(t) ];

case 1:
return r = s.sent(), [ 4, this._cache.getStoreAsync(n) ];

case 2:
return i = s.sent(), r ? i && i > Date.now() ? [ 4, (o = new Ne({
envId: this._config.env,
cache: this._cache,
request: this._request
})).checkLocalStateAsync() ] : [ 3, 4 ] : [ 3, 7 ];

case 3:
return s.sent(), [ 2, o ];

case 4:
return [ 4, this._cache.removeStoreAsync(t) ];

case 5:
return s.sent(), [ 4, this._cache.removeStoreAsync(n) ];

case 6:
s.sent(), s.label = 7;

case 7:
return [ 2 ];
}
});
});
}, e.prototype.setRefreshToken = function(e) {
return o(this, void 0, void 0, function() {
var t, n, r, i;
return s(this, function(o) {
switch (o.label) {
case 0:
return t = this._cache.keys, n = t.accessTokenKey, r = t.accessTokenExpireKey, i = t.refreshTokenKey, 
[ 4, this._cache.removeStoreAsync(n) ];

case 1:
return o.sent(), [ 4, this._cache.removeStoreAsync(r) ];

case 2:
return o.sent(), [ 4, this._cache.setStoreAsync(i, e) ];

case 3:
return o.sent(), [ 2 ];
}
});
});
}, e.prototype.setAccessToken = function(e, t) {
return o(this, void 0, void 0, function() {
var n, r, i;
return s(this, function(o) {
switch (o.label) {
case 0:
return n = this._cache.keys, r = n.accessTokenKey, i = n.accessTokenExpireKey, [ 4, this._cache.setStoreAsync(r, e) ];

case 1:
return o.sent(), [ 4, this._cache.setStoreAsync(i, t) ];

case 2:
return o.sent(), [ 2 ];
}
});
});
}, e.prototype.refreshUserInfo = function() {
return o(this, void 0, void 0, function() {
var e;
return s(this, function(t) {
switch (t.label) {
case 0:
return [ 4, this._request.send("auth.getUserInfo", {}) ];

case 1:
return e = t.sent().data, [ 4, this.setLocalUserInfo(e) ];

case 2:
return t.sent(), [ 2, e ];
}
});
});
}, e.prototype.setLocalUserInfo = function(e) {
return o(this, void 0, void 0, function() {
var t;
return s(this, function(n) {
switch (n.label) {
case 0:
return t = this._cache.keys.userInfoKey, [ 4, this._cache.setStoreAsync(t, e) ];

case 1:
return n.sent(), [ 2 ];
}
});
});
}, e;
}();
!function(e) {
e.ANONYMOUS = "ANONYMOUS", e.WECHAT = "WECHAT", e.WECHAT_PUBLIC = "WECHAT-PUBLIC", 
e.WECHAT_OPEN = "WECHAT-OPEN", e.CUSTOM = "CUSTOM", e.EMAIL = "EMAIL", e.USERNAME = "USERNAME", 
e.NULL = "NULL";
}(r || (r = {}));
var u, c = (u = function(e, t) {
return (u = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
})(e, t);
}, function(e, t) {
function n() {
this.constructor = e;
}
u(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
new n());
}), f = function(e, t, n, r) {
var i, o = arguments.length, s = o < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, n) : r;
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, n, r); else for (var a = e.length - 1; a >= 0; a--) (i = e[a]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, n, s) : i(t, n)) || s);
return o > 3 && s && Object.defineProperty(t, n, s), s;
}, l = function(e, t) {
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(e, t);
}, h = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, p = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, d = i.constants.getSdkName, y = i.constants.ERRORS, _ = i.constants.COMMUNITY_SITE_URL, g = i.adapters.RUNTIME, v = i.utils.getQuery, m = i.utils.getHash, b = i.utils.removeParam, w = i.utils.printWarn, E = i.helpers.catchErrorsDecorator, S = function(e) {
function t(t, n, r, i) {
var o = e.call(this, t) || this;
return o._runtime = t.runtime, o._appid = n, o._scope = r, o._state = i || "weixin", 
o;
}
return c(t, e), t.prototype.signIn = function() {
return h(this, void 0, void 0, function() {
return p(this, function() {
return [ 2, w(y.OPERATION_FAIL, "API signIn has been deprecated, please use signInWithRedirect insteed") ];
});
});
}, t.prototype.signInWithRedirect = function() {
return h(this, void 0, void 0, function() {
return p(this, function() {
return [ 2, this._redirect() ];
});
});
}, t.prototype.getRedirectResult = function(e) {
return h(this, void 0, void 0, function() {
var t;
return p(this, function() {
return (t = A()) ? [ 2, this._signInWithCode(t, e) ] : [ 2, null ];
});
});
}, t.prototype.getLinkRedirectResult = function(e) {
return void 0 === e && (e = {}), h(this, void 0, void 0, function() {
var t, n, r, i, o, s;
return p(this, function() {
return t = e.withUnionId, n = void 0 !== t && t, (r = A()) ? (i = this._appid, o = function(e) {
switch (e) {
case "snsapi_login":
return "WECHAT-OPEN";

default:
return "WECHAT-PUBLIC";
}
}(this._scope), s = this._runtime === g.WX_MP ? "1" : "0", [ 2, this._request.send("auth.linkWithWeixinCode", {
payload: {
appid: i,
loginType: o,
code: r,
hybridMiniapp: s,
withUnionId: n
}
}) ]) : [ 2, null ];
});
});
}, t.prototype._redirect = function() {
var e = b("code", location.href);
e = b("state", e), e = encodeURIComponent(e);
var t = "//open.weixin.qq.com/connect/oauth2/authorize";
"snsapi_login" === this._scope && (t = "//open.weixin.qq.com/connect/qrconnect");
try {
location.href = t + "?appid=" + this._appid + "&redirect_uri=" + e + "&response_type=code&scope=" + this._scope + "&state=" + this._state + "#wechat_redirect";
} catch (e) {
throw new Error("[" + d() + "][" + y.UNKOWN_ERROR + "]" + e);
}
}, t.prototype._signInWithCode = function(e, t) {
return h(this, void 0, void 0, function() {
var n, i, o, s, a, u, c, f;
return p(this, function(l) {
switch (l.label) {
case 0:
return n = this._cache.keys, i = n.accessTokenKey, o = n.accessTokenExpireKey, s = n.refreshTokenKey, 
a = function(e) {
switch (e) {
case "snsapi_login":
return "WECHAT-OPEN";

default:
return "WECHAT-PUBLIC";
}
}(this._scope), [ 4, this._getRefreshTokenByWXCode(this._appid, a, e, t) ];

case 1:
return u = l.sent(), c = u.refreshToken, [ 4, this._cache.setStoreAsync(s, c) ];

case 2:
return l.sent(), u.accessToken ? [ 4, this._cache.setStoreAsync(i, u.accessToken) ] : [ 3, 4 ];

case 3:
l.sent(), l.label = 4;

case 4:
return u.accessTokenExpire ? [ 4, this._cache.setStoreAsync(o, String(u.accessTokenExpire + Date.now())) ] : [ 3, 6 ];

case 5:
l.sent(), l.label = 6;

case 6:
return Ie.fire(Pe.LOGIN_STATE_CHANGED), Ie.fire(Pe.LOGIN_TYPE_CHANGED, {
env: this._config.env,
loginType: r.WECHAT,
persistence: this._config.persistence
}), [ 4, this.refreshUserInfo() ];

case 7:
return l.sent(), [ 4, (f = new Ne({
envId: this._config.env,
cache: this._cache,
request: this._request
})).checkLocalStateAsync() ];

case 8:
return l.sent(), [ 2, f ];
}
});
});
}, t.prototype._getRefreshTokenByWXCode = function(e, t, n, r) {
return void 0 === r && (r = {}), h(this, void 0, void 0, function() {
var i, o, s, a, u, c;
return p(this, function() {
return i = r.withUnionId, o = void 0 !== i && i, s = r.createUser, a = void 0 === s || s, 
u = "snsapi_base" !== this._scope && (r.syncUserInfo || !1), c = this._runtime === g.WX_MP ? "1" : "0", 
[ 2, this._request.send("auth.signIn", {
appid: e,
loginType: t,
hybridMiniapp: c,
syncUserInfo: u,
loginCredential: n,
withUnionId: o,
createUser: a
}).then(function(e) {
if (e.code) throw new Error("[" + d() + "][" + y.OPERATION_FAIL + "] failed login via wechat: " + e.code);
if (e.refresh_token) return {
refreshToken: e.refresh_token,
accessToken: e.access_token,
accessTokenExpire: e.access_token_expire
};
throw new Error("[" + d() + "][" + y.OPERATION_FAIL + "] action:getJwt not return refreshToken");
}) ];
});
});
}, f([ E({
title: "跳转微信公众号授权失败",
messages: [ "请确认以下各项：", "  1 - 调用 auth().weixinAuthProvider().signInWithRedirect() 的语法或参数是否正确", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + _ ]
}), l("design:type", Function), l("design:paramtypes", []), l("design:returntype", Promise) ], t.prototype, "signInWithRedirect", null), 
f([ E({
title: "微信公众号登录失败",
messages: [ "请确认以下各项：", "  1 - 调用 auth().weixinAuthProvider().getRedirectResult() 的语法或参数是否正确", "  2 - 当前环境是否开通了微信公众号登录授权", "  3 - 微信公众号的 AppId 与 AppSecret 配置是否正确", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + _ ]
}), l("design:type", Function), l("design:paramtypes", [ Object ]), l("design:returntype", Promise) ], t.prototype, "getRedirectResult", null), 
f([ E({
title: "获取微信重定向绑定结果",
messages: [ "请确认以下各项：", "  1 - 调用 auth().weixinAuthProvider().getLinkRedirectResult() 的语法或参数是否正确", "  2 - 当前环境是否开通了微信公众号登录授权", "  3 - 微信公众号的 AppId 与 AppSecret 配置是否正确", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + _ ]
}), l("design:type", Function), l("design:paramtypes", [ Object ]), l("design:returntype", Promise) ], t.prototype, "getLinkRedirectResult", null), 
t;
}(a);
function A() {
return v("code") || m("code");
}
var O = function() {
var e = function(t, n) {
return (e = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
})(t, n);
};
return function(t, n) {
function r() {
this.constructor = t;
}
e(t, n), t.prototype = null === n ? Object.create(n) : (r.prototype = n.prototype, 
new r());
};
}(), I = function(e, t, n, r) {
var i, o = arguments.length, s = o < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, n) : r;
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, n, r); else for (var a = e.length - 1; a >= 0; a--) (i = e[a]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, n, s) : i(t, n)) || s);
return o > 3 && s && Object.defineProperty(t, n, s), s;
}, T = function(e, t) {
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(e, t);
}, N = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, R = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, P = i.constants.ERRORS, B = i.constants.COMMUNITY_SITE_URL, D = i.utils.throwError, C = i.utils.isString, L = i.events.addEventListener, x = i.helpers.catchErrorsDecorator, k = function(e) {
function t(t) {
var n = e.call(this, t) || this;
return n._onConverted = n._onConverted.bind(n), L(Pe.ANONYMOUS_CONVERTED, n._onConverted), 
n;
}
return O(t, e), t.prototype.signIn = function() {
return N(this, void 0, void 0, function() {
var e, t, n, i, o, s, a;
return R(this, function(u) {
switch (u.label) {
case 0:
return [ 4, this._cache.updatePersistenceAsync("local") ];

case 1:
return u.sent(), e = this._cache.keys, t = e.anonymousUuidKey, n = e.refreshTokenKey, 
[ 4, this._cache.getStoreAsync(t) ];

case 2:
return i = u.sent(), [ 4, this._cache.getStoreAsync(n) ];

case 3:
return o = u.sent(), [ 4, this._request.send("auth.signInAnonymously", {
anonymous_uuid: i,
refresh_token: o
}) ];

case 4:
return (s = u.sent()).uuid && s.refresh_token ? [ 4, this._setAnonymousUUID(s.uuid) ] : [ 3, 10 ];

case 5:
return u.sent(), [ 4, this.setRefreshToken(s.refresh_token) ];

case 6:
return u.sent(), [ 4, this._request.refreshAccessToken() ];

case 7:
return u.sent(), Ie.fire(Pe.LOGIN_TYPE_CHANGED, {
env: this._config.env,
loginType: r.ANONYMOUS,
persistence: "local"
}), Ie.fire(Pe.LOGIN_STATE_CHANGED), [ 4, (a = new Ne({
envId: this._config.env,
cache: this._cache,
request: this._request
})).checkLocalStateAsync() ];

case 8:
return u.sent(), [ 4, a.user.refresh() ];

case 9:
return u.sent(), [ 2, a ];

case 10:
throw new Error(JSON.stringify({
code: P.OPERATION_FAIL,
msg: JSON.stringify(s) || "anonymous signIn failed"
}));
}
});
});
}, t.prototype.linkAndRetrieveDataWithTicket = function(e) {
return N(this, void 0, void 0, function() {
var t, n, i, o, s, a, u;
return R(this, function(c) {
switch (c.label) {
case 0:
return C(e) || D(P.INVALID_PARAMS, "ticket must be a string"), t = this._cache.keys, 
n = t.anonymousUuidKey, i = t.refreshTokenKey, [ 4, this._cache.getStoreAsync(n) ];

case 1:
return o = c.sent(), [ 4, this._cache.getStoreAsync(i) ];

case 2:
return s = c.sent(), [ 4, this._request.send("auth.linkAndRetrieveDataWithTicket", {
anonymous_uuid: o,
refresh_token: s,
ticket: e
}) ];

case 3:
return (a = c.sent()).refresh_token ? [ 4, this._clearAnonymousUUID() ] : [ 3, 8 ];

case 4:
return c.sent(), [ 4, this.setRefreshToken(a.refresh_token) ];

case 5:
return c.sent(), [ 4, this._request.refreshAccessToken() ];

case 6:
return c.sent(), Ie.fire(Pe.ANONYMOUS_CONVERTED, {
env: this._config.env
}), Ie.fire(Pe.LOGIN_TYPE_CHANGED, {
loginType: r.CUSTOM,
persistence: "local"
}), [ 4, (u = new Ne({
envId: this._config.env,
cache: this._cache,
request: this._request
})).checkLocalStateAsync() ];

case 7:
return c.sent(), [ 2, u ];

case 8:
D(P.OPERATION_FAIL, JSON.stringify(a) || "linkAndRetrieveDataWithTicket failed"), 
c.label = 9;

case 9:
return [ 2 ];
}
});
});
}, t.prototype._setAnonymousUUID = function(e) {
return N(this, void 0, void 0, function() {
var t, n, i;
return R(this, function(o) {
switch (o.label) {
case 0:
return t = this._cache.keys, n = t.anonymousUuidKey, i = t.loginTypeKey, [ 4, this._cache.removeStoreAsync(n) ];

case 1:
return o.sent(), [ 4, this._cache.setStoreAsync(n, e) ];

case 2:
return o.sent(), [ 4, this._cache.setStoreAsync(i, r.ANONYMOUS) ];

case 3:
return o.sent(), [ 2 ];
}
});
});
}, t.prototype._clearAnonymousUUID = function() {
return N(this, void 0, void 0, function() {
return R(this, function(e) {
switch (e.label) {
case 0:
return [ 4, this._cache.removeStoreAsync(this._cache.keys.anonymousUuidKey) ];

case 1:
return e.sent(), [ 2 ];
}
});
});
}, t.prototype._onConverted = function(e) {
return N(this, void 0, void 0, function() {
return R(this, function(t) {
switch (t.label) {
case 0:
return e.data.env !== this._config.env ? [ 2 ] : [ 4, this._cache.updatePersistenceAsync(this._config.persistence) ];

case 1:
return t.sent(), [ 2 ];
}
});
});
}, I([ x({
title: "匿名登录失败",
messages: [ "请确认以下各项：", "  1 - 当前环境是否开启了匿名登录", "  2 - 调用 auth().anonymouseProvider().signIn() 的语法或参数是否正确", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + B ]
}), T("design:type", Function), T("design:paramtypes", []), T("design:returntype", Promise) ], t.prototype, "signIn", null), 
t;
}(a), U = function() {
var e = function(t, n) {
return (e = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
})(t, n);
};
return function(t, n) {
function r() {
this.constructor = t;
}
e(t, n), t.prototype = null === n ? Object.create(n) : (r.prototype = n.prototype, 
new r());
};
}(), M = function(e, t, n, r) {
var i, o = arguments.length, s = o < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, n) : r;
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, n, r); else for (var a = e.length - 1; a >= 0; a--) (i = e[a]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, n, s) : i(t, n)) || s);
return o > 3 && s && Object.defineProperty(t, n, s), s;
}, j = function(e, t) {
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(e, t);
}, $ = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, q = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, F = i.constants.ERRORS, W = i.constants.COMMUNITY_SITE_URL, z = i.utils.isString, K = i.helpers.catchErrorsDecorator, G = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this;
}
return U(t, e), t.prototype.signIn = function(e) {
return $(this, void 0, void 0, function() {
var t, n, i, o, s, a, u;
return q(this, function(c) {
switch (c.label) {
case 0:
if (!z(e)) throw new Error(JSON.stringify({
code: F.INVALID_PARAMS,
msg: "ticket must be a string"
}));
return t = this._cache.keys.refreshTokenKey, o = (i = this._request).send, s = [ "auth.signInWithTicket" ], 
a = {
ticket: e
}, [ 4, this._cache.getStoreAsync(t) ];

case 1:
return [ 4, o.apply(i, s.concat([ (a.refresh_token = c.sent() || "", a) ])) ];

case 2:
return (n = c.sent()).refresh_token ? [ 4, this.setRefreshToken(n.refresh_token) ] : [ 3, 7 ];

case 3:
return c.sent(), [ 4, this._request.refreshAccessToken() ];

case 4:
return c.sent(), Ie.fire(Pe.LOGIN_TYPE_CHANGED, {
env: this._config.env,
loginType: r.CUSTOM,
persistence: this._config.persistence
}), Ie.fire(Pe.LOGIN_STATE_CHANGED), [ 4, this.refreshUserInfo() ];

case 5:
return c.sent(), [ 4, (u = new Ne({
envId: this._config.env,
cache: this._cache,
request: this._request
})).checkLocalStateAsync() ];

case 6:
return c.sent(), [ 2, u ];

case 7:
throw new Error(JSON.stringify({
code: F.OPERATION_FAIL,
msg: "custom signIn failed"
}));
}
});
});
}, M([ K({
title: "自定义登录失败",
messages: [ "请确认以下各项：", "  1 - 当前环境是否开启了自定义登录", "  2 - 调用 auth().customAuthProvider().signIn() 的语法或参数是否正确", "  3 - ticket 是否归属于当前环境", "  4 - 创建 ticket 的自定义登录私钥是否过期", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + W ]
}), j("design:type", Function), j("design:paramtypes", [ String ]), j("design:returntype", Promise) ], t.prototype, "signIn", null), 
t;
}(a), Y = function() {
var e = function(t, n) {
return (e = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
})(t, n);
};
return function(t, n) {
function r() {
this.constructor = t;
}
e(t, n), t.prototype = null === n ? Object.create(n) : (r.prototype = n.prototype, 
new r());
};
}(), H = function(e, t, n, r) {
var i, o = arguments.length, s = o < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, n) : r;
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, n, r); else for (var a = e.length - 1; a >= 0; a--) (i = e[a]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, n, s) : i(t, n)) || s);
return o > 3 && s && Object.defineProperty(t, n, s), s;
}, J = function(e, t) {
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(e, t);
}, V = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, X = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, Q = i.utils.throwError, Z = i.utils.isString, ee = i.constants.ERRORS, te = i.constants.COMMUNITY_SITE_URL, ne = i.helpers.catchErrorsDecorator, re = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this;
}
return Y(t, e), t.prototype.signIn = function(e, t) {
return V(this, void 0, void 0, function() {
var n, i, o, s, a;
return X(this, function(u) {
switch (u.label) {
case 0:
return Z(e) || Q(ee.INVALID_PARAMS, "email must be a string"), n = this._cache.keys.refreshTokenKey, 
[ 4, this._request.send("auth.signIn", {
loginType: "EMAIL",
email: e,
password: t,
refresh_token: this._cache.getStore(n) || ""
}) ];

case 1:
return i = u.sent(), o = i.refresh_token, s = i.access_token, a = i.access_token_expire, 
o ? [ 4, this.setRefreshToken(o) ] : [ 3, 8 ];

case 2:
return u.sent(), s && a ? [ 4, this.setAccessToken(s, a) ] : [ 3, 4 ];

case 3:
return u.sent(), [ 3, 6 ];

case 4:
return [ 4, this._request.refreshAccessToken() ];

case 5:
u.sent(), u.label = 6;

case 6:
return [ 4, this.refreshUserInfo() ];

case 7:
return u.sent(), Ie.fire(Pe.LOGIN_STATE_CHANGED), Ie.fire(Pe.LOGIN_TYPE_CHANGED, {
env: this._config.env,
loginType: r.EMAIL,
persistence: this._config.persistence
}), [ 2, new Ne({
envId: this._config.env,
cache: this._cache,
request: this._request
}) ];

case 8:
i.code ? Q(ee.OPERATION_FAIL, "Email login fail[" + i.code + "] " + i.message) : Q(ee.OPERATION_FAIL, "Email login fail"), 
u.label = 9;

case 9:
return [ 2 ];
}
});
});
}, t.prototype.signUp = function(e, t) {
return V(this, void 0, void 0, function() {
return X(this, function() {
return [ 2, this._request.send("auth.signUpWithEmailAndPassword", {
email: e,
password: t
}) ];
});
});
}, t.prototype.resetPassword = function(e) {
return V(this, void 0, void 0, function() {
return X(this, function() {
return [ 2, this._request.send("auth.sendPasswordResetEmail", {
email: e
}) ];
});
});
}, t.prototype.resetPasswordWithToken = function(e, t) {
return V(this, void 0, void 0, function() {
return X(this, function() {
return [ 2, this._request.send("auth.resetPasswordWithToken", {
token: e,
newPassword: t
}) ];
});
});
}, t.prototype.activate = function(e) {
return V(this, void 0, void 0, function() {
return X(this, function() {
return [ 2, this._request.send("auth.activateEndUserMail", {
token: e
}) ];
});
});
}, H([ ne({
title: "邮箱密码登录失败",
messages: [ "请确认以下各项：", "  1 - 调用 auth().emailAuthProvider() 的语法或参数是否正确", "  2 - 当前环境是否开通了邮箱登录", "  3 - 邮箱地址与密码是否匹配", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + te ]
}), J("design:type", Function), J("design:paramtypes", [ String, String ]), J("design:returntype", Promise) ], t.prototype, "signIn", null), 
H([ ne({
title: "邮箱注册失败",
messages: [ "请确认以下各项：", "  1 - 调用 auth().signUpWithEmailAndPassword() 的语法或参数是否正确", "  2 - 当前环境是否开通了邮箱登录", "  3 - 此邮箱地址是否已经被其他用户占用", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + te ]
}), J("design:type", Function), J("design:paramtypes", [ String, String ]), J("design:returntype", Promise) ], t.prototype, "signUp", null), 
H([ ne({
title: "重置密码失败",
messages: [ "请确认以下各项：", "  1 - 调用 auth().sendPasswordResetEmail() 的语法或参数是否正确", "  2 - 当前环境是否开通了邮箱登录", "  3 - 此邮箱地址是否已经与当前用户绑定", "  4 - 此邮箱地址是否已经被其他用户占用", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + te ]
}), J("design:type", Function), J("design:paramtypes", [ String ]), J("design:returntype", Promise) ], t.prototype, "resetPassword", null), 
H([ ne({
title: "重置密码失败",
messages: [ "请确认以下各项：", "  1 - 调用语法或参数是否正确", "  2 - 当前环境是否开通了邮箱登录", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + te ]
}), J("design:type", Function), J("design:paramtypes", [ String, String ]), J("design:returntype", Promise) ], t.prototype, "resetPasswordWithToken", null), 
H([ ne({
title: "邮箱激活失败",
messages: [ "请确认以下各项：", "  1 - 调用语法或参数是否正确", "  2 - 当前环境是否开通了邮箱登录", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + te ]
}), J("design:type", Function), J("design:paramtypes", [ String ]), J("design:returntype", Promise) ], t.prototype, "activate", null), 
t;
}(a), ie = function() {
var e = function(t, n) {
return (e = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
})(t, n);
};
return function(t, n) {
function r() {
this.constructor = t;
}
e(t, n), t.prototype = null === n ? Object.create(n) : (r.prototype = n.prototype, 
new r());
};
}(), oe = function(e, t, n, r) {
var i, o = arguments.length, s = o < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, n) : r;
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, n, r); else for (var a = e.length - 1; a >= 0; a--) (i = e[a]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, n, s) : i(t, n)) || s);
return o > 3 && s && Object.defineProperty(t, n, s), s;
}, se = function(e, t) {
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(e, t);
}, ae = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, ue = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, ce = i.utils.printWarn, fe = i.constants.ERRORS, le = i.constants.COMMUNITY_SITE_URL, he = i.helpers.catchErrorsDecorator, pe = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this;
}
return ie(t, e), t.prototype.signIn = function(e, t) {
return ae(this, void 0, void 0, function() {
var n, i, o, s, a, u, c, f, l;
return ue(this, function(h) {
switch (h.label) {
case 0:
if ("string" != typeof e) throw new Error(JSON.stringify({
code: fe.INVALID_PARAMS,
msg: "username must be a string"
}));
return "string" != typeof t && (t = "", ce(fe.INVALID_PARAMS, "password is empty")), 
n = this._cache.keys.refreshTokenKey, s = (o = this._request).send, a = [ "auth.signIn" ], 
u = {
loginType: r.USERNAME,
username: e,
password: t
}, [ 4, this._cache.getStoreAsync(n) ];

case 1:
return [ 4, s.apply(o, a.concat([ (u.refresh_token = h.sent() || "", u) ])) ];

case 2:
return i = h.sent(), c = i.refresh_token, f = i.access_token_expire, l = i.access_token, 
c ? [ 4, this.setRefreshToken(c) ] : [ 3, 9 ];

case 3:
return h.sent(), l && f ? [ 4, this.setAccessToken(l, f) ] : [ 3, 5 ];

case 4:
return h.sent(), [ 3, 7 ];

case 5:
return [ 4, this._request.refreshAccessToken() ];

case 6:
h.sent(), h.label = 7;

case 7:
return [ 4, this.refreshUserInfo() ];

case 8:
return h.sent(), Ie.fire(Pe.LOGIN_STATE_CHANGED), Ie.fire(Pe.LOGIN_TYPE_CHANGED, {
env: this._config.env,
loginType: r.USERNAME,
persistence: this._config.persistence
}), [ 2, new Ne({
envId: this._config.env,
cache: this._cache,
request: this._request
}) ];

case 9:
throw i.code ? new Error(JSON.stringify({
code: fe.OPERATION_FAIL,
msg: "login by username failed:[" + i.code + "] " + i.message
})) : new Error(JSON.stringify({
code: fe.OPERATION_FAIL,
msg: "login by username failed"
}));

case 10:
return [ 2 ];
}
});
});
}, oe([ he({
title: "用户名密码登录失败",
messages: [ "请确认以下各项：", "  1 - 调用 auth().signInWithUsernameAndPassword() 的语法或参数是否正确", "  2 - 当前环境是否开通了用户名密码登录", "  3 - 用户名密码是否匹配", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + le ]
}), se("design:type", Function), se("design:paramtypes", [ String, String ]), se("design:returntype", Promise) ], t.prototype, "signIn", null), 
t;
}(a), de = function() {
return (de = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}).apply(this, arguments);
}, ye = function(e, t, n, r) {
var i, o = arguments.length, s = o < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, n) : r;
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, n, r); else for (var a = e.length - 1; a >= 0; a--) (i = e[a]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, n, s) : i(t, n)) || s);
return o > 3 && s && Object.defineProperty(t, n, s), s;
}, _e = function(e, t) {
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(e, t);
}, ge = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, ve = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, me = i.events.CloudbaseEventEmitter, be = i.adapters.RUNTIME, we = i.utils.printWarn, Ee = i.utils.throwError, Se = i.constants.ERRORS, Ae = i.constants.COMMUNITY_SITE_URL, Oe = i.helpers.catchErrorsDecorator, Ie = new me(), Te = function() {
function e(e) {
var t = e.cache, n = e.request;
this._cache = t, this._request = n, this._setUserInfo();
}
return e.prototype.checkLocalInfo = function() {
return ge(this, void 0, void 0, function() {
return ve(this, function() {
return this.uid = this._getLocalUserInfo("uid"), this.loginType = this._getLocalUserInfo("loginType"), 
this.openid = this._getLocalUserInfo("wxOpenId"), this.wxOpenId = this._getLocalUserInfo("wxOpenId"), 
this.wxPublicId = this._getLocalUserInfo("wxPublicId"), this.unionId = this._getLocalUserInfo("wxUnionId"), 
this.qqMiniOpenId = this._getLocalUserInfo("qqMiniOpenId"), this.customUserId = this._getLocalUserInfo("customUserId"), 
this.nickName = this._getLocalUserInfo("nickName"), this.gender = this._getLocalUserInfo("gender"), 
this.avatarUrl = this._getLocalUserInfo("avatarUrl"), this.email = this._getLocalUserInfo("email"), 
this.hasPassword = Boolean(this._getLocalUserInfo("hasPassword")), this.location = {
country: this._getLocalUserInfo("country"),
province: this._getLocalUserInfo("province"),
city: this._getLocalUserInfo("city")
}, [ 2 ];
});
});
}, e.prototype.checkLocalInfoAsync = function() {
return ge(this, void 0, void 0, function() {
var e, t, n, r, i, o, s, a, u, c, f, l, h, p, d, y;
return ve(this, function(_) {
switch (_.label) {
case 0:
return e = this, [ 4, this._getLocalUserInfoAsync("uid") ];

case 1:
return e.uid = _.sent(), t = this, [ 4, this._getLocalUserInfoAsync("loginType") ];

case 2:
return t.loginType = _.sent(), n = this, [ 4, this._getLocalUserInfoAsync("wxOpenId") ];

case 3:
return n.openid = _.sent(), r = this, [ 4, this._getLocalUserInfoAsync("wxOpenId") ];

case 4:
return r.wxOpenId = _.sent(), i = this, [ 4, this._getLocalUserInfoAsync("wxPublicId") ];

case 5:
return i.wxPublicId = _.sent(), o = this, [ 4, this._getLocalUserInfoAsync("wxUnionId") ];

case 6:
return o.unionId = _.sent(), s = this, [ 4, this._getLocalUserInfoAsync("qqMiniOpenId") ];

case 7:
return s.qqMiniOpenId = _.sent(), a = this, [ 4, this._getLocalUserInfoAsync("customUserId") ];

case 8:
return a.customUserId = _.sent(), u = this, [ 4, this._getLocalUserInfoAsync("nickName") ];

case 9:
return u.nickName = _.sent(), c = this, [ 4, this._getLocalUserInfoAsync("gender") ];

case 10:
return c.gender = _.sent(), f = this, [ 4, this._getLocalUserInfoAsync("avatarUrl") ];

case 11:
return f.avatarUrl = _.sent(), l = this, [ 4, this._getLocalUserInfoAsync("email") ];

case 12:
return l.email = _.sent(), h = this, p = Boolean, [ 4, this._getLocalUserInfoAsync("hasPassword") ];

case 13:
return h.hasPassword = p.apply(void 0, [ _.sent() ]), d = this, y = {}, [ 4, this._getLocalUserInfoAsync("country") ];

case 14:
return y.country = _.sent(), [ 4, this._getLocalUserInfoAsync("province") ];

case 15:
return y.province = _.sent(), [ 4, this._getLocalUserInfoAsync("city") ];

case 16:
return d.location = (y.city = _.sent(), y), [ 2 ];
}
});
});
}, e.prototype.linkWithTicket = function(e) {
if ("string" != typeof e) throw new Error("ticket must be string");
return this._request.send("auth.linkWithTicket", {
ticket: e
});
}, e.prototype.linkWithRedirect = function(e) {
e.signInWithRedirect();
}, e.prototype.getLinkedUidList = function() {
return ge(this, void 0, void 0, function() {
var e, t, n, r, i, o;
return ve(this, function(s) {
switch (s.label) {
case 0:
return [ 4, this._request.send("auth.getLinkedUidList", {}) ];

case 1:
for (e = s.sent().data, t = !1, n = e.users, r = 0, i = n; r < i.length; r++) if ((o = i[r]).wxOpenId && o.wxPublicId) {
t = !0;
break;
}
return [ 2, {
users: n,
hasPrimaryUid: t
} ];
}
});
});
}, e.prototype.setPrimaryUid = function(e) {
return this._request.send("auth.setPrimaryUid", {
uid: e
});
}, e.prototype.unlink = function(e) {
return this._request.send("auth.unlink", {
platform: e
});
}, e.prototype.update = function(e) {
return ge(this, void 0, void 0, function() {
var t, n, r, i, o, s, a;
return ve(this, function(u) {
switch (u.label) {
case 0:
return t = e.nickName, n = e.gender, r = e.avatarUrl, i = e.province, o = e.country, 
s = e.city, [ 4, this._request.send("auth.updateUserInfo", {
nickName: t,
gender: n,
avatarUrl: r,
province: i,
country: o,
city: s
}) ];

case 1:
return a = u.sent().data, this._setLocalUserInfo(a), [ 2 ];
}
});
});
}, e.prototype.updatePassword = function(e, t) {
return this._request.send("auth.updatePassword", {
oldPassword: t,
newPassword: e
});
}, e.prototype.updateEmail = function(e) {
return this._request.send("auth.updateEmail", {
newEmail: e
});
}, e.prototype.updateUsername = function(e) {
return "string" != typeof e && Ee(Se.INVALID_PARAMS, "username must be a string"), 
this._request.send("auth.updateUsername", {
username: e
});
}, e.prototype.refresh = function() {
return ge(this, void 0, void 0, function() {
var e;
return ve(this, function(t) {
switch (t.label) {
case 0:
return [ 4, this._request.send("auth.getUserInfo", {}) ];

case 1:
return e = t.sent().data, this._setLocalUserInfo(e), [ 2, e ];
}
});
});
}, e.prototype._getLocalUserInfo = function(e) {
var t = this._cache.keys.userInfoKey;
return this._cache.getStore(t)[e];
}, e.prototype._getLocalUserInfoAsync = function(e) {
return ge(this, void 0, void 0, function() {
var t;
return ve(this, function(n) {
switch (n.label) {
case 0:
return t = this._cache.keys.userInfoKey, [ 4, this._cache.getStoreAsync(t) ];

case 1:
return [ 2, n.sent()[e] ];
}
});
});
}, e.prototype._setUserInfo = function() {
var e = this, t = this._cache.keys.userInfoKey, n = this._cache.getStore(t);
[ "uid", "loginType", "openid", "wxOpenId", "wxPublicId", "unionId", "qqMiniOpenId", "email", "hasPassword", "customUserId", "nickName", "gender", "avatarUrl" ].forEach(function(t) {
e[t] = n[t];
}), this.location = {
country: n.country,
province: n.province,
city: n.city
};
}, e.prototype._setLocalUserInfo = function(e) {
var t = this._cache.keys.userInfoKey;
this._cache.setStore(t, e), this._setUserInfo();
}, ye([ Oe({
title: "绑定自定义登录失败",
messages: [ "请确认以下各项：", "  1 - 调用 User.linkWithTicket() 的语法或参数是否正确", "  2 - 此账户是否已经绑定自定义登录", "  3 - ticket 参数是否归属当前环境", "  4 - 创建 ticket 的自定义登录私钥是否过期", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", [ String ]), _e("design:returntype", Promise) ], e.prototype, "linkWithTicket", null), 
ye([ Oe({
title: "绑定第三方登录方式失败",
messages: [ "请确认以下各项：", "  1 - 调用 User.linkWithRedirect() 的语法或参数是否正确", "  2 - 此账户是否已经绑定此第三方", "  3 - 此第三方是否已经授权", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", [ Object ]), _e("design:returntype", void 0) ], e.prototype, "linkWithRedirect", null), 
ye([ Oe({
title: "获取账户列表失败",
messages: [ "请确认以下各项：", "  1 - 调用 User.getLinkedUidList() 的语法或参数是否正确", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", []), _e("design:returntype", Promise) ], e.prototype, "getLinkedUidList", null), 
ye([ Oe({
title: "设置微信主账号失败",
messages: [ "请确认以下各项：", "  1 - 调用 User.setPrimaryUid() 的语法或参数是否正确", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", [ String ]), _e("design:returntype", void 0) ], e.prototype, "setPrimaryUid", null), 
ye([ Oe({
title: "接触绑定失败",
messages: [ "请确认以下各项：", "  1 - 调用 User.unlink() 的语法或参数是否正确", "  2 - 当前账户是否已经与此登录方式解绑", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", [ String ]), _e("design:returntype", void 0) ], e.prototype, "unlink", null), 
ye([ Oe({
title: "更新用户信息失败",
messages: [ "请确认以下各项：", "  1 - 调用 User.update() 的语法或参数是否正确", "  2 - 用户信息中是否包含非法值", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", [ Object ]), _e("design:returntype", Promise) ], e.prototype, "update", null), 
ye([ Oe({
title: "更新密码失败",
messages: [ "请确认以下各项：", "  1 - 调用 User.updatePassword() 的语法或参数是否正确", "  3 - 新密码中是否包含非法字符", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", [ String, String ]), _e("design:returntype", void 0) ], e.prototype, "updatePassword", null), 
ye([ Oe({
title: "更新邮箱地址失败",
messages: [ "请确认以下各项：", "  1 - 调用 User.updateEmail() 的语法或参数是否正确", "  2 - 当前环境是否开通了邮箱密码登录", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", [ String ]), _e("design:returntype", void 0) ], e.prototype, "updateEmail", null), 
ye([ Oe({
title: "更新用户名失败",
messages: [ "请确认以下各项：", "  1 - 调用 User.updateUsername() 的语法或参数是否正确", "  2 - 当前环境是否开通了用户名密码登录", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", [ String ]), _e("design:returntype", void 0) ], e.prototype, "updateUsername", null), 
ye([ Oe({
title: "刷新本地用户信息失败",
messages: [ "请确认以下各项：", "  1 - 调用 User.refresh() 的语法或参数是否正确", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", []), _e("design:returntype", Promise) ], e.prototype, "refresh", null), 
e;
}(), Ne = function() {
function e(e) {
var t = e.envId, n = e.cache, r = e.request;
t || Ee(Se.INVALID_PARAMS, "envId is not defined"), this._cache = n, this.user = new Te({
cache: n,
request: r
});
}
return e.prototype.checkLocalState = function() {
return ge(this, void 0, void 0, function() {
var e, t, n, r, i, o, s;
return ve(this, function() {
return e = this._cache.keys, t = e.refreshTokenKey, n = e.accessTokenKey, r = e.accessTokenExpireKey, 
i = this._cache.getStore(t), o = this._cache.getStore(n), s = this._cache.getStore(r), 
this.credential = {
refreshToken: i,
accessToken: o,
accessTokenExpire: s
}, this._loginType = this._cache.getStore(this._cache.keys.loginTypeKey), this.user.checkLocalInfo(), 
[ 2 ];
});
});
}, e.prototype.checkLocalStateAsync = function() {
return ge(this, void 0, void 0, function() {
var e, t, n, r, i, o, s, a;
return ve(this, function(u) {
switch (u.label) {
case 0:
return e = this._cache.keys, t = e.refreshTokenKey, n = e.accessTokenKey, r = e.accessTokenExpireKey, 
[ 4, this._cache.getStoreAsync(t) ];

case 1:
return i = u.sent(), [ 4, this._cache.getStoreAsync(n) ];

case 2:
return o = u.sent(), [ 4, this._cache.getStoreAsync(r) ];

case 3:
return s = u.sent(), this.credential = {
refreshToken: i,
accessToken: o,
accessTokenExpire: s
}, a = this, [ 4, this._cache.getStoreAsync(this._cache.keys.loginTypeKey) ];

case 4:
return a._loginType = u.sent(), [ 4, this.user.checkLocalInfoAsync() ];

case 5:
return u.sent(), [ 2 ];
}
});
});
}, Object.defineProperty(e.prototype, "isAnonymousAuth", {
get: function() {
return this.loginType === r.ANONYMOUS;
},
enumerable: !1,
configurable: !0
}), Object.defineProperty(e.prototype, "isCustomAuth", {
get: function() {
return this.loginType === r.CUSTOM;
},
enumerable: !1,
configurable: !0
}), Object.defineProperty(e.prototype, "isWeixinAuth", {
get: function() {
return this.loginType === r.WECHAT || this.loginType === r.WECHAT_OPEN || this.loginType === r.WECHAT_PUBLIC;
},
enumerable: !1,
configurable: !0
}), Object.defineProperty(e.prototype, "isUsernameAuth", {
get: function() {
return this.loginType === r.USERNAME;
},
enumerable: !1,
configurable: !0
}), Object.defineProperty(e.prototype, "loginType", {
get: function() {
return this._loginType;
},
enumerable: !1,
configurable: !0
}), e;
}(), Re = function() {
function e(e) {
this._config = e, this._cache = e.cache, this._request = e.request, this._runtime = e.runtime || be.WEB, 
Ie.on(Pe.LOGIN_TYPE_CHANGED, this._onLoginTypeChanged.bind(this));
}
return Object.defineProperty(e.prototype, "currentUser", {
get: function() {
if ("async" !== this._cache.mode) {
var e = this.hasLoginState();
return e && e.user || null;
}
we(Se.INVALID_OPERATION, "current platform's storage is asynchronous, please use getCurrenUser insteed");
},
enumerable: !1,
configurable: !0
}), Object.defineProperty(e.prototype, "loginType", {
get: function() {
return this._cache.getStore(this._cache.keys.loginTypeKey);
},
enumerable: !1,
configurable: !0
}), e.prototype.getCurrenUser = function() {
return ge(this, void 0, void 0, function() {
var e;
return ve(this, function(t) {
switch (t.label) {
case 0:
return [ 4, this.getLoginState() ];

case 1:
return (e = t.sent()) ? [ 4, e.user.checkLocalInfoAsync() ] : [ 3, 3 ];

case 2:
return t.sent(), [ 2, e.user || null ];

case 3:
return [ 2, null ];
}
});
});
}, e.prototype.getLoginType = function() {
return ge(this, void 0, void 0, function() {
return ve(this, function(e) {
switch (e.label) {
case 0:
return [ 4, this._cache.getStoreAsync(this._cache.keys.loginTypeKey) ];

case 1:
return [ 2, e.sent() ];
}
});
});
}, e.prototype.getAccessToken = function() {
return ge(this, void 0, void 0, function() {
var e;
return ve(this, function(t) {
switch (t.label) {
case 0:
return e = {}, [ 4, this._request.getAccessToken() ];

case 1:
return [ 2, (e.accessToken = t.sent().accessToken, e.env = this._config.env, e) ];
}
});
});
}, e.prototype.weixinAuthProvider = function(e) {
var t = e.appid, n = e.scope, r = e.state;
return this._weixinAuthProvider || (this._weixinAuthProvider = new S(de(de({}, this._config), {
cache: this._cache,
request: this._request,
runtime: this._runtime
}), t, n, r)), this._weixinAuthProvider;
}, e.prototype.anonymousAuthProvider = function() {
return this._anonymousAuthProvider || (this._anonymousAuthProvider = new k(de(de({}, this._config), {
cache: this._cache,
request: this._request
}))), this._anonymousAuthProvider;
}, e.prototype.customAuthProvider = function() {
return this._customAuthProvider || (this._customAuthProvider = new G(de(de({}, this._config), {
cache: this._cache,
request: this._request
}))), this._customAuthProvider;
}, e.prototype.emailAuthProvider = function() {
return this._emailAuthProvider || (this._emailAuthProvider = new re(de(de({}, this._config), {
cache: this._cache,
request: this._request
}))), this._emailAuthProvider;
}, e.prototype.usernameAuthProvider = function() {
return this._usernameAuthProvider || (this._usernameAuthProvider = new pe(de(de({}, this._config), {
cache: this._cache,
request: this._request
}))), this._usernameAuthProvider;
}, e.prototype.signInWithUsernameAndPassword = function(e, t) {
return ge(this, void 0, void 0, function() {
return ve(this, function() {
return [ 2, this.usernameAuthProvider().signIn(e, t) ];
});
});
}, e.prototype.isUsernameRegistered = function(e) {
return ge(this, void 0, void 0, function() {
var t;
return ve(this, function(n) {
switch (n.label) {
case 0:
return "string" != typeof e && Ee(Se.INVALID_PARAMS, "username must be a string"), 
[ 4, this._request.send("auth.isUsernameRegistered", {
username: e
}) ];

case 1:
return [ 2, null == (t = n.sent().data) ? void 0 : t.isRegistered ];
}
});
});
}, e.prototype.signInWithEmailAndPassword = function(e, t) {
return ge(this, void 0, void 0, function() {
return ve(this, function() {
return [ 2, this.emailAuthProvider().signIn(e, t) ];
});
});
}, e.prototype.signUpWithEmailAndPassword = function(e, t) {
return ge(this, void 0, void 0, function() {
return ve(this, function() {
return [ 2, this.emailAuthProvider().signUp(e, t) ];
});
});
}, e.prototype.sendPasswordResetEmail = function(e) {
return ge(this, void 0, void 0, function() {
return ve(this, function() {
return [ 2, this.emailAuthProvider().resetPassword(e) ];
});
});
}, e.prototype.signOut = function() {
return ge(this, void 0, void 0, function() {
var e, t, n, i, o, s, a;
return ve(this, function(u) {
switch (u.label) {
case 0:
return [ 4, this.getLoginType() ];

case 1:
if (u.sent() === r.ANONYMOUS) throw new Error(JSON.stringify({
code: Se.INVALID_OPERATION,
msg: "anonymous user doesn't support signOut action"
}));
return e = this._cache.keys, t = e.refreshTokenKey, n = e.accessTokenKey, i = e.accessTokenExpireKey, 
o = "auth.logout", [ 4, this._cache.getStoreAsync(t) ];

case 2:
return (s = u.sent()) ? [ 4, this._request.send(o, {
refresh_token: s
}) ] : [ 2 ];

case 3:
return a = u.sent(), this._cache.removeStoreAsync(t), this._cache.removeStoreAsync(n), 
this._cache.removeStoreAsync(i), Ie.fire(Pe.LOGIN_STATE_CHANGED), Ie.fire(Pe.LOGIN_TYPE_CHANGED, {
env: this._config.env,
loginType: r.NULL,
persistence: this._config.persistence
}), [ 2, a ];
}
});
});
}, e.prototype.onLoginStateChanged = function(e) {
return ge(this, void 0, void 0, function() {
var t, n = this;
return ve(this, function(r) {
switch (r.label) {
case 0:
return Ie.on(Pe.LOGIN_STATE_CHANGED, function() {
return ge(n, void 0, void 0, function() {
var t;
return ve(this, function(n) {
switch (n.label) {
case 0:
return [ 4, this.getLoginState() ];

case 1:
return t = n.sent(), e.call(this, t), [ 2 ];
}
});
});
}), [ 4, this.getLoginState() ];

case 1:
return t = r.sent(), e.call(this, t), [ 2 ];
}
});
});
}, e.prototype.onLoginStateExpired = function(e) {
Ie.on(Pe.LOGIN_STATE_EXPIRED, e.bind(this));
}, e.prototype.onAccessTokenRefreshed = function(e) {
Ie.on(Pe.ACCESS_TOKEN_REFRESHD, e.bind(this));
}, e.prototype.onAnonymousConverted = function(e) {
Ie.on(Pe.ANONYMOUS_CONVERTED, e.bind(this));
}, e.prototype.onLoginTypeChanged = function(e) {
var t = this;
Ie.on(Pe.LOGIN_TYPE_CHANGED, function() {
return ge(t, void 0, void 0, function() {
var t;
return ve(this, function(n) {
switch (n.label) {
case 0:
return [ 4, this.getLoginState() ];

case 1:
return t = n.sent(), e.call(this, t), [ 2 ];
}
});
});
});
}, e.prototype.hasLoginState = function() {
if ("async" !== this._cache.mode) {
var e = this._cache.keys.refreshTokenKey;
if (this._cache.getStore(e)) {
var t = new Ne({
envId: this._config.env,
cache: this._cache,
request: this._request
});
return t.checkLocalState(), t;
}
return null;
}
we(Se.INVALID_OPERATION, "current platform's storage is asynchronous, please use getLoginState insteed");
}, e.prototype.getLoginState = function() {
return ge(this, void 0, void 0, function() {
var e, t;
return ve(this, function(n) {
switch (n.label) {
case 0:
return e = this._cache.keys.refreshTokenKey, [ 4, this._cache.getStoreAsync(e) ];

case 1:
return n.sent() ? [ 4, (t = new Ne({
envId: this._config.env,
cache: this._cache,
request: this._request
})).checkLocalStateAsync() ] : [ 3, 3 ];

case 2:
return n.sent(), [ 2, t ];

case 3:
return [ 2, null ];
}
});
});
}, e.prototype.shouldRefreshAccessToken = function(e) {
this._request._shouldRefreshAccessTokenHook = e.bind(this);
}, e.prototype.getUserInfo = function() {
return ge(this, void 0, void 0, function() {
var e;
return ve(this, function(t) {
switch (t.label) {
case 0:
return [ 4, this._request.send("auth.getUserInfo", {}) ];

case 1:
return (e = t.sent()).code ? [ 2, e ] : [ 2, de(de({}, e.data), {
requestId: e.seqId
}) ];
}
});
});
}, e.prototype.getAuthHeader = function() {
var e = this._cache.keys, t = e.refreshTokenKey, n = e.accessTokenKey, r = this._cache.getStore(t);
return {
"x-cloudbase-credentials": this._cache.getStore(n) + "/@@/" + r
};
}, e.prototype.getAuthHeaderAsync = function() {
return ge(this, void 0, void 0, function() {
var e, t, n, r;
return ve(this, function(i) {
switch (i.label) {
case 0:
return [ 4, this._request.refreshAccessToken() ];

case 1:
return i.sent(), e = this._cache.keys, t = e.refreshTokenKey, n = e.accessTokenKey, 
[ 4, this._cache.getStoreAsync(t) ];

case 2:
return r = i.sent(), [ 4, this._cache.getStoreAsync(n) ];

case 3:
return [ 2, {
"x-cloudbase-credentials": i.sent() + "/@@/" + r
} ];
}
});
});
}, e.prototype._onLoginTypeChanged = function(e) {
return ge(this, void 0, void 0, function() {
var t, n, r;
return ve(this, function(i) {
switch (i.label) {
case 0:
return t = e.data, n = t.loginType, r = t.persistence, t.env !== this._config.env ? [ 2 ] : [ 4, this._cache.updatePersistenceAsync(r) ];

case 1:
return i.sent(), [ 4, this._cache.setStoreAsync(this._cache.keys.loginTypeKey, n) ];

case 2:
return i.sent(), [ 2 ];
}
});
});
}, ye([ Oe({
title: "获取用户信息失败",
messages: [ "请确认以下各项：", "  1 - 调用 auth().getCurrenUser() 的语法或参数是否正确", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", []), _e("design:returntype", Promise) ], e.prototype, "getCurrenUser", null), 
ye([ Oe({
title: "获取用户是否被占用失败",
messages: [ "请确认以下各项：", "  1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", [ String ]), _e("design:returntype", Promise) ], e.prototype, "isUsernameRegistered", null), 
ye([ Oe({
title: "用户登出失败",
messages: [ "请确认以下各项：", "  1 - 调用 auth().signOut() 的语法或参数是否正确", "  2 - 当前用户是否为匿名登录（匿名登录不支持signOut）", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", []), _e("design:returntype", Promise) ], e.prototype, "signOut", null), 
ye([ Oe({
title: "获取本地登录态失败",
messages: [ "请确认以下各项：", "  1 - 调用 auth().getLoginState() 的语法或参数是否正确", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", []), _e("design:returntype", Promise) ], e.prototype, "getLoginState", null), 
ye([ Oe({
title: "获取用户信息失败",
messages: [ "请确认以下各项：", "  1 - 是否已登录", "  2 - 调用 auth().getUserInfo() 的语法或参数是否正确", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + Ae ]
}), _e("design:type", Function), _e("design:paramtypes", []), _e("design:returntype", Promise) ], e.prototype, "getUserInfo", null), 
e;
}(), Pe = {
LOGIN_STATE_CHANGED: "loginStateChanged",
LOGIN_STATE_EXPIRED: "loginStateExpire",
LOGIN_TYPE_CHANGED: "loginTypeChanged",
ANONYMOUS_CONVERTED: "anonymousConverted",
ACCESS_TOKEN_REFRESHD: "refreshAccessToken"
}, Be = {
name: "auth",
namespace: "auth",
injectEvents: {
bus: Ie,
events: [ Pe.LOGIN_TYPE_CHANGED, Pe.LOGIN_STATE_EXPIRED, Pe.LOGIN_STATE_CHANGED, Pe.ACCESS_TOKEN_REFRESHD, Pe.ANONYMOUS_CONVERTED ]
},
entity: function(e) {
if (void 0 === e && (e = {
persistence: "session"
}), this.authInstance) return we(Se.INVALID_OPERATION, "every cloudbase instance should has only one auth object"), 
this.authInstance;
var t = this.platform, n = t.adapter, r = t.runtime, i = e.persistence || n.primaryStorage;
i && i !== this.config.persistence && this.updateConfig({
persistence: i
});
var o = this.config, s = o.env, a = o.persistence, u = o.debug;
return this.authInstance = new Re({
env: s,
persistence: a,
debug: u,
cache: this.cache,
request: this.request,
runtime: r
}), this.authInstance;
}
};
try {
cloudbase.registerComponent(Be);
} catch (e) {}
function De(e) {
try {
e.registerComponent(Be);
} catch (e) {
console.warn(e);
}
}
function Ce(e, t) {
Re.prototype[e] = function(n) {
var r = "_" + e;
return this[r] || (this[r] = new t(de(de({}, n), this._config))), this[r];
};
}
}, function(e, t, n) {
"use strict";
n.r(t), n.d(t, "cloudbase", function() {
return te;
});
var r, i = n(0), o = n(4), s = (r = function(e, t) {
return (r = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
})(e, t);
}, function(e, t) {
function n() {
this.constructor = e;
}
r(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
new n());
}), a = function() {
return (a = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}).apply(this, arguments);
}, u = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, c = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, f = function(e) {
function t(t) {
void 0 === t && (t = {});
var n = e.call(this) || this, r = t.timeout, i = t.timeoutMsg, o = t.restrictedMethods;
return n._timeout = r || 0, n._timeoutMsg = i || "请求超时", n._restrictedMethods = o || [ "get", "post", "upload", "download" ], 
n;
}
return s(t, e), t.prototype.post = function(e) {
var t = this;
return new Promise(function(n, r) {
var i = e.url, s = e.data, a = e.headers, u = wx.request({
url: Object(o.formatUrl)("https:", i),
data: s,
timeout: t._timeout,
method: "POST",
header: a,
success: function(e) {
n(e);
},
fail: function(e) {
r(e);
},
complete: function(e) {
if (e && e.errMsg && t._timeout && -1 !== t._restrictedMethods.indexOf("post") && "request:fail timeout" === e.errMsg) {
console.warn(t._timeoutMsg);
try {
u.abort();
} catch (e) {}
}
}
});
});
}, t.prototype.upload = function(e) {
var t = this, n = this;
return new Promise(function(r) {
return u(t, void 0, void 0, function() {
var t, i, o, s, u, f;
return c(this, function() {
return t = e.url, i = e.file, o = e.data, s = e.headers, u = e.onUploadProgress, 
f = wx.uploadFile({
url: t,
filePath: i,
name: "file",
formData: a({}, o),
header: s,
timeout: this._timeout,
success: function(e) {
var t = {
statusCode: e.statusCode,
data: e.data || {}
};
200 === e.statusCode && o.success_action_status && (t.statusCode = parseInt(o.success_action_status, 10)), 
r(t);
},
fail: function(e) {
r(e);
},
complete: function(e) {
if (e && e.errMsg && n._timeout && -1 !== n._restrictedMethods.indexOf("upload") && "request:fail timeout" === e.errMsg) {
console.warn(n._timeoutMsg);
try {
f.abort();
} catch (e) {}
}
}
}), u && f.onProgressUpdate(function(e) {
u(e);
}), [ 2 ];
});
});
});
}, t.prototype.download = function(e) {
var t = this, n = this;
return new Promise(function(r, i) {
var s = e.url, a = e.headers, u = wx.downloadFile({
url: Object(o.formatUrl)("https:", s),
header: a,
timeout: t._timeout,
success: function(e) {
200 === e.statusCode && e.tempFilePath ? r({
statusCode: 200,
tempFilePath: e.tempFilePath
}) : r(e);
},
fail: function(e) {
i(e);
},
complete: function(e) {
if (e && e.errMsg && n._timeout && -1 !== n._restrictedMethods.indexOf("download") && "request:fail timeout" === e.errMsg) {
console.warn(n._timeoutMsg);
try {
u.abort();
} catch (e) {}
}
}
});
});
}, t;
}(o.AbstractSDKRequest), l = {
setItem: function(e, t) {
wx.setStorageSync(e, t);
},
getItem: function(e) {
return wx.getStorageSync(e);
},
removeItem: function(e) {
wx.removeStorageSync(e);
},
clear: function() {
wx.clearStorageSync();
}
}, h = function(e, t) {
void 0 === t && (t = {});
var n = wx.connectSocket(a({
url: e
}, t));
return {
set onopen(e) {
n.onOpen(e);
},
set onmessage(e) {
n.onMessage(e);
},
set onclose(e) {
n.onClose(e);
},
set onerror(e) {
n.onError(e);
},
send: function(e) {
return n.send({
data: e
});
},
close: function(e, t) {
return n.close({
code: e,
reason: t
});
},
get readyState() {
return n.readyState;
},
CONNECTING: 0,
OPEN: 1,
CLOSING: 2,
CLOSED: 3
};
}, p = {
genAdapter: function() {
return {
root: {},
reqClass: f,
wsClass: h,
localStorage: l,
primaryStorage: o.StorageType.local,
getAppSign: function() {
var e = wx.getAccountInfoSync();
return "undefined" != typeof App || "undefined" != typeof getApp || wx.onAppHide || wx.offAppHide || wx.onAppShow || wx.offAppShow ? e && e.miniProgram ? e.miniProgram.appId : "" : e && e.plugin ? e.plugin.appId : "";
}
};
},
isMatch: function() {
if ("undefined" == typeof wx) return !1;
if ("undefined" == typeof Page) return !1;
if (!wx.getSystemInfoSync) return !1;
if (!wx.getStorageSync) return !1;
if (!wx.setStorageSync) return !1;
if (!wx.connectSocket) return !1;
if (!wx.request) return !1;
try {
if (!wx.getSystemInfoSync()) return !1;
if ("qq" === wx.getSystemInfoSync().AppPlatform) return !1;
} catch (e) {
return !1;
}
return !0;
},
runtime: "wx_mp"
}, d = function() {
for (var e = 0, t = 0, n = arguments.length; t < n; t++) e += arguments[t].length;
var r = Array(e), i = 0;
for (t = 0; t < n; t++) for (var o = arguments[t], s = 0, a = o.length; s < a; s++, 
i++) r[i] = o[s];
return r;
}, y = i.constants.ERRORS, _ = {};
function g(e, t) {
var n = t.name, r = t.namespace, i = t.entity, o = t.injectEvents, s = t.IIFE, a = void 0 !== s && s;
if (_[n] || r && e[r]) throw new Error(JSON.stringify({
code: y.INVALID_OPERATION,
msg: "Duplicate component " + n
}));
if (a) {
if (!i || "function" != typeof i) throw new Error(JSON.stringify({
code: y.INVALID_PARAMS,
msg: "IIFE component's entity must be a function"
}));
i.call(e);
}
if (_[n] = t, r ? e.prototype[r] = i : function e(t, n) {
if (!(n instanceof Object)) return n;
switch (n.constructor) {
case Date:
return new Date(n.getTime());

case Object:
void 0 === t && (t = {});
break;

case Array:
t = [];
break;

default:
return n;
}
for (var r in n) n.hasOwnProperty(r) && (t[r] = e(t[r], n[r]));
return t;
}(e.prototype, i), o) {
var u = o.bus, c = o.events;
if (!u || !c || 0 === c.length) return;
var f = e.prototype.fire || function() {};
e.prototype.events || (e.prototype.events = {}), (e.prototype.events || {})[n] ? e.prototype.events[n].events = d(e.prototype.events[n].events, c) : e.prototype.events[n] = {
bus: u,
events: c
}, e.prototype.fire = function(e, t) {
for (var n in f(e, t), this.events) {
var r = this.events[n], i = r.bus;
if (r.events.includes(e)) {
i.fire(e, t);
break;
}
}
};
}
}
var v = {}, m = function() {
return (m = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}).apply(this, arguments);
}, b = i.cache.CloudbaseCache, w = {}, E = {};
function S(e) {
var t = e.env, n = e.persistence, r = e.platformInfo, i = {
accessTokenKey: "access_token_" + t,
accessTokenExpireKey: "access_token_expire_" + t,
refreshTokenKey: "refresh_token_" + t,
anonymousUuidKey: "anonymous_uuid_" + t,
loginTypeKey: "login_type_" + t,
userInfoKey: "user_info_" + t
};
w[t] ? w[t].updatePersistence(n) : w[t] = new b(m(m({}, e), {
keys: i,
platformInfo: r,
alwaysLocalKeys: [ "anonymousUuidKey" ]
})), E[t] = E[t] || new b(m(m({}, e), {
keys: i,
platformInfo: r,
persistence: "local"
}));
}
function A(e) {
return w[e];
}
function O(e) {
return E[e];
}
var I = n(2), T = function() {
return (T = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}).apply(this, arguments);
}, N = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, R = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, P = i.constants.ERRORS, B = i.utils.genSeqId, D = i.utils.isFormData, C = i.utils.formatUrl, L = i.utils.createSign, x = i.adapters.RUNTIME, k = [ "auth.getJwt", "auth.logout", "auth.signInWithTicket", "auth.signInAnonymously", "auth.signIn", "auth.fetchAccessTokenWithRefreshToken", "auth.signUpWithEmailAndPassword", "auth.activateEndUserMail", "auth.sendPasswordResetEmail", "auth.resetPasswordWithToken", "auth.isUsernameRegistered" ];
function U(e, t, n) {
var r = e[t];
e[t] = function(t) {
var i = {}, o = {};
n.forEach(function(n) {
var r = n.call(e, t), s = r.data, a = r.headers;
Object.assign(i, s), Object.assign(o, a);
});
var s = t.data;
return s && function() {
if (D(s)) for (var e in i) s.append(e, i[e]); else t.data = T(T({}, s), i);
}(), t.headers = T(T({}, t.headers || {}), o), r.call(e, t);
};
}
function M() {
var e = B();
return {
data: {
seqId: e
},
headers: {
"X-SDK-Version": "@cloudbase/js-sdk/" + Object(I.e)(),
"x-seqid": e
}
};
}
var j = function() {
function e(e) {
this._throwWhenRequestFail = !1, this.config = e, this._reqClass = new v.adapter.reqClass({
timeout: this.config.timeout,
timeoutMsg: "[@cloudbase/js-sdk] 请求在" + this.config.timeout / 1e3 + "s内未完成，已中断",
restrictedMethods: [ "post" ]
}), this._throwWhenRequestFail = e.throw || !1, this._cache = A(this.config.env), 
this._localCache = O(this.config.env), U(this._reqClass, "post", [ M ]), U(this._reqClass, "upload", [ M ]), 
U(this._reqClass, "download", [ M ]);
}
return e.prototype.post = function(e) {
return N(this, void 0, void 0, function() {
return R(this, function(t) {
switch (t.label) {
case 0:
return [ 4, this._reqClass.post(e) ];

case 1:
return [ 2, t.sent() ];
}
});
});
}, e.prototype.upload = function(e) {
return N(this, void 0, void 0, function() {
return R(this, function(t) {
switch (t.label) {
case 0:
return [ 4, this._reqClass.upload(e) ];

case 1:
return [ 2, t.sent() ];
}
});
});
}, e.prototype.download = function(e) {
return N(this, void 0, void 0, function() {
return R(this, function(t) {
switch (t.label) {
case 0:
return [ 4, this._reqClass.download(e) ];

case 1:
return [ 2, t.sent() ];
}
});
});
}, e.prototype.refreshAccessToken = function() {
return N(this, void 0, void 0, function() {
var e, t, n;
return R(this, function(r) {
switch (r.label) {
case 0:
this._refreshAccessTokenPromise || (this._refreshAccessTokenPromise = this._refreshAccessToken()), 
r.label = 1;

case 1:
return r.trys.push([ 1, 3, , 4 ]), [ 4, this._refreshAccessTokenPromise ];

case 2:
return e = r.sent(), [ 3, 4 ];

case 3:
return n = r.sent(), t = n, [ 3, 4 ];

case 4:
if (this._refreshAccessTokenPromise = null, this._shouldRefreshAccessTokenHook = null, 
t) throw t;
return [ 2, e ];
}
});
});
}, e.prototype.getAccessToken = function() {
return N(this, void 0, void 0, function() {
var e, t, n, r, i, o, s, a, u;
return R(this, function(c) {
switch (c.label) {
case 0:
return e = this._cache.keys, t = e.accessTokenKey, n = e.accessTokenExpireKey, r = e.refreshTokenKey, 
[ 4, this._cache.getStoreAsync(r) ];

case 1:
if (!c.sent()) throw new Error(JSON.stringify({
code: P.OPERATION_FAIL,
msg: "refresh token is not exist, your local data might be messed up, please retry after clear localStorage or sessionStorage"
}));
return [ 4, this._cache.getStoreAsync(t) ];

case 2:
return i = c.sent(), s = Number, [ 4, this._cache.getStoreAsync(n) ];

case 3:
return o = s.apply(void 0, [ c.sent() ]), a = !0, (u = this._shouldRefreshAccessTokenHook) ? [ 4, this._shouldRefreshAccessTokenHook(i, o) ] : [ 3, 5 ];

case 4:
u = !c.sent(), c.label = 5;

case 5:
return u && (a = !1), i && o && !(o < Date.now()) || !a ? [ 3, 7 ] : [ 4, this.refreshAccessToken() ];

case 6:
return [ 2, c.sent() ];

case 7:
return [ 2, {
accessToken: i,
accessTokenExpire: o
} ];
}
});
});
}, e.prototype.request = function(e, t, n) {
return N(this, void 0, void 0, function() {
var r, i, o, s, a, u, c, f, l, h, p, d, y, _, g, m, b, w, E, S, A, O, N, P, B, D;
return R(this, function(R) {
switch (R.label) {
case 0:
return r = "x-tcb-trace_" + this.config.env, i = "application/x-www-form-urlencoded", 
o = T({
action: e,
dataVersion: I.a,
env: this.config.env
}, t), -1 !== k.indexOf(e) ? [ 3, 3 ] : (s = this._cache.keys.refreshTokenKey, [ 4, this._cache.getStoreAsync(s) ]);

case 1:
return R.sent() ? (a = o, [ 4, this.getAccessToken() ]) : [ 3, 3 ];

case 2:
a.access_token = R.sent().accessToken, R.label = 3;

case 3:
if ("storage.uploadFile" === e) {
for (c in u = new FormData()) u.hasOwnProperty(c) && void 0 !== u[c] && u.append(c, o[c]);
i = "multipart/form-data";
} else for (c in i = "application/json;charset=UTF-8", u = {}, o) void 0 !== o[c] && (u[c] = o[c]);
return f = {
headers: {
"content-type": i
}
}, (null == n ? void 0 : n.onUploadProgress) && (f.onUploadProgress = n.onUploadProgress), 
(l = this._localCache.getStore(r)) && (f.headers["X-TCB-Trace"] = l), v.runtime !== x.WEB && (h = this.config, 
p = h.appSign, d = h.appSecret, y = Date.now(), _ = d.appAccessKey, g = d.appAccessKeyId, 
m = L({
data: u,
timestamp: y,
appAccessKeyId: g,
appSign: p
}, _), f.headers["X-TCB-App-Source"] = "timestamp=" + y + ";appAccessKeyId=" + g + ";appSign=" + p + ";sign=" + m), 
b = t.parse, w = t.inQuery, E = t.search, S = {
env: this.config.env
}, b && (S.parse = !0), w && (S = T(T({}, w), S)), A = Object(I.c)(), O = A.BASE_URL, 
N = A.PROTOCOL, P = C(N, O, S), E && (P += E), [ 4, this.post(T({
url: P,
data: u
}, f)) ];

case 4:
if (B = R.sent(), (D = B.header && B.header["x-tcb-trace"]) && this._localCache.setStore(r, D), 
200 !== Number(B.status) && 200 !== Number(B.statusCode) || !B.data) throw new Error("network request error");
return [ 2, B ];
}
});
});
}, e.prototype.send = function(e, t) {
return void 0 === t && (t = {}), N(this, void 0, void 0, function() {
var n;
return R(this, function(r) {
switch (r.label) {
case 0:
return [ 4, this.request(e, t, {
onUploadProgress: t.onUploadProgress
}) ];

case 1:
return "ACCESS_TOKEN_EXPIRED" !== (n = r.sent()).data.code || -1 !== k.indexOf(e) ? [ 3, 4 ] : [ 4, this.refreshAccessToken() ];

case 2:
return r.sent(), [ 4, this.request(e, t, {
onUploadProgress: t.onUploadProgress
}) ];

case 3:
n = r.sent(), r.label = 4;

case 4:
if (n.data.code && this._throwWhenRequestFail) throw new Error(JSON.stringify({
code: P.OPERATION_FAIL,
msg: "[" + n.data.code + "] " + n.data.message
}));
return [ 2, n.data ];
}
});
});
}, e.prototype._refreshAccessToken = function() {
return N(this, void 0, void 0, function() {
var e, t, n, r, i, o, s, a, u, c, f, l, h;
return R(this, function(p) {
switch (p.label) {
case 0:
return e = this._cache.keys, t = e.accessTokenKey, n = e.accessTokenExpireKey, r = e.refreshTokenKey, 
i = e.loginTypeKey, o = e.anonymousUuidKey, [ 4, this._cache.removeStoreAsync(t) ];

case 1:
return p.sent(), [ 4, this._cache.removeStoreAsync(n) ];

case 2:
return p.sent(), [ 4, this._cache.getStoreAsync(r) ];

case 3:
if (!(s = p.sent())) throw new Error(JSON.stringify({
code: P.INVALID_OPERATION,
msg: "not login"
}));
return a = {
refresh_token: s
}, [ 4, this.request("auth.fetchAccessTokenWithRefreshToken", a) ];

case 4:
return (u = p.sent()).data.code ? "SIGN_PARAM_INVALID" !== (c = u.data.code) && "REFRESH_TOKEN_EXPIRED" !== c && "INVALID_REFRESH_TOKEN" !== c ? [ 3, 11 ] : [ 4, this._cache.getStoreAsync(i) ] : [ 3, 12 ];

case 5:
return p.sent() === I.b.ANONYMOUS && "INVALID_REFRESH_TOKEN" === c ? [ 4, this._cache.getStoreAsync(o) ] : [ 3, 9 ];

case 6:
return f = p.sent(), [ 4, this._cache.getStoreAsync(r) ];

case 7:
return l = p.sent(), [ 4, this.send("auth.signInAnonymously", {
anonymous_uuid: f,
refresh_token: l
}) ];

case 8:
return h = p.sent(), this._setRefreshToken(h.refresh_token), [ 2, this._refreshAccessToken() ];

case 9:
return te.fire("loginStateExpire"), [ 4, this._cache.removeStoreAsync(r) ];

case 10:
p.sent(), p.label = 11;

case 11:
throw new Error(JSON.stringify({
code: P.NETWORK_ERROR,
msg: "refresh access_token failed：" + u.data.code
}));

case 12:
return u.data.access_token ? (te.fire("refreshAccessToken"), [ 4, this._cache.setStoreAsync(t, u.data.access_token) ]) : [ 3, 15 ];

case 13:
return p.sent(), [ 4, this._cache.setStoreAsync(n, u.data.access_token_expire + Date.now()) ];

case 14:
return p.sent(), [ 2, {
accessToken: u.data.access_token,
accessTokenExpire: u.data.access_token_expire
} ];

case 15:
return u.data.refresh_token ? [ 4, this._cache.removeStoreAsync(r) ] : [ 3, 19 ];

case 16:
return p.sent(), [ 4, this._cache.setStoreAsync(r, u.data.refresh_token) ];

case 17:
return p.sent(), [ 4, this._refreshAccessToken() ];

case 18:
p.sent(), p.label = 19;

case 19:
return [ 2 ];
}
});
});
}, e.prototype._setRefreshToken = function(e) {
return N(this, void 0, void 0, function() {
var t, n, r, i;
return R(this, function(o) {
switch (o.label) {
case 0:
return t = this._cache.keys, n = t.accessTokenKey, r = t.accessTokenExpireKey, i = t.refreshTokenKey, 
[ 4, this._cache.removeStoreAsync(n) ];

case 1:
return o.sent(), [ 4, this._cache.removeStoreAsync(r) ];

case 2:
return o.sent(), [ 4, this._cache.setStoreAsync(i, e) ];

case 3:
return o.sent(), [ 2 ];
}
});
});
}, e;
}(), $ = {}, q = function() {
return (q = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}).apply(this, arguments);
}, F = function(e, t, n, r) {
var i, o = arguments.length, s = o < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, n) : r;
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, n, r); else for (var a = e.length - 1; a >= 0; a--) (i = e[a]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, n, s) : i(t, n)) || s);
return o > 3 && s && Object.defineProperty(t, n, s), s;
}, W = function(e, t) {
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(e, t);
}, z = function(e, t, n, r) {
return new (n || (n = Promise))(function(i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}, K = function(e, t) {
var n, r, i, o, s = {
label: 0,
sent: function() {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: []
};
return o = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
return this;
}), o;
function a(o) {
return function(a) {
return function(o) {
if (n) throw new TypeError("Generator is already executing.");
for (;s; ) try {
if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 
0) : r.next) && !(i = i.call(r, o[1])).done) return i;
switch (r = 0, i && (o = [ 2 & o[0], i.value ]), o[0]) {
case 0:
case 1:
i = o;
break;

case 4:
return s.label++, {
value: o[1],
done: !1
};

case 5:
s.label++, r = o[1], o = [ 0 ];
continue;

case 7:
o = s.ops.pop(), s.trys.pop();
continue;

default:
if (!(i = s.trys, (i = i.length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
s = 0;
continue;
}
if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
s.label = o[1];
break;
}
if (6 === o[0] && s.label < i[1]) {
s.label = i[1], i = o;
break;
}
if (i && s.label < i[2]) {
s.label = i[2], s.ops.push(o);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
o = t.call(e, s);
} catch (e) {
o = [ 6, e ], r = 0;
} finally {
n = i = 0;
}
if (5 & o[0]) throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
};
}([ o, a ]);
};
}
}, G = i.adapters.useAdapters, Y = i.adapters.useDefaultAdapter, H = i.adapters.RUNTIME, J = i.constants.ERRORS, V = i.constants.COMMUNITY_SITE_URL, X = i.utils.printWarn, Q = i.helpers.catchErrorsDecorator, Z = {
timeout: 15e3,
persistence: "session"
}, ee = {}, te = new (function() {
function e(e) {
this._config = e || this._config, this.authInstance = null;
}
return Object.defineProperty(e.prototype, "config", {
get: function() {
return this._config;
},
enumerable: !1,
configurable: !0
}), Object.defineProperty(e.prototype, "platform", {
get: function() {
return v;
},
enumerable: !1,
configurable: !0
}), Object.defineProperty(e.prototype, "cache", {
get: function() {
return A(this._config.env);
},
enumerable: !1,
configurable: !0
}), Object.defineProperty(e.prototype, "localCache", {
get: function() {
return O(this._config.env);
},
enumerable: !1,
configurable: !0
}), Object.defineProperty(e.prototype, "request", {
get: function() {
return e = this._config.env, $[e];
var e;
},
enumerable: !1,
configurable: !0
}), e.prototype.init = function(t) {
if (!t.env) throw new Error(JSON.stringify({
code: J.INVALID_PARAMS,
msg: "env must not be specified"
}));
if (v.adapter || this._useDefaultAdapter(), this.requestClient = new v.adapter.reqClass({
timeout: t.timeout || 5e3,
timeoutMsg: "[" + Object(I.d)() + "][REQUEST TIMEOUT] request had been abort since didn't finished within" + t.timeout / 1e3 + "s"
}), v.runtime !== H.WEB) {
if (!t.appSecret) throw new Error(JSON.stringify({
code: J.INVALID_PARAMS,
msg: "invalid appSecret"
}));
var n = v.adapter.getAppSign ? v.adapter.getAppSign() : "";
if (t.appSign && n && t.appSign !== n) throw new Error(JSON.stringify({
code: J.INVALID_PARAMS,
msg: "invalid appSign"
}));
if (n && (t.appSign = n), !t.appSign) throw new Error(JSON.stringify({
code: J.INVALID_PARAMS,
msg: "invalid appSign"
}));
}
this._config = q(q({}, Z), t), this._config.timeout = this._formatTimeout(this._config.timeout);
var r = this._config, i = r.env, o = r.persistence, s = r.debug, a = r.timeout, u = r.appSecret, c = r.appSign;
return S({
env: i,
persistence: o,
debug: s,
platformInfo: this.platform
}), function(e) {
$[e.env] = new j(T(T({}, e), {
throw: !0
}));
}({
env: i,
timeout: a,
appSecret: u,
appSign: c
}), new e(this._config);
}, e.prototype.updateConfig = function(e) {
var t = e.persistence, n = e.debug;
this._config.persistence = t, this._config.debug = n, S({
env: this._config.env,
persistence: t,
debug: n,
platformInfo: this.platform
});
}, e.prototype.registerExtension = function(e) {
ee[e.name] = e;
}, e.prototype.invokeExtension = function(e, t) {
return z(this, void 0, void 0, function() {
var n;
return K(this, function(r) {
switch (r.label) {
case 0:
if (!(n = ee[e])) throw new Error(JSON.stringify({
code: J.INVALID_PARAMS,
msg: "extension:" + e + " must be registered before invoke"
}));
return [ 4, n.invoke(t, this) ];

case 1:
return [ 2, r.sent() ];
}
});
});
}, e.prototype.useAdapters = function(e) {
var t = G(e) || {}, n = t.adapter, r = t.runtime;
n && (v.adapter = n), r && (v.runtime = r);
}, e.prototype.registerHook = function(t) {
!function(e, t) {
var n = t.entity, r = t.target;
if (!e.prototype.hasOwnProperty(r)) throw new Error(JSON.stringify({
code: y.INVALID_OPERATION,
msg: "target:" + r + " is not exist"
}));
var i = e.prototype[r];
if ("function" != typeof i) throw new Error(JSON.stringify({
code: y.INVALID_OPERATION,
msg: "target:" + r + " is not a function which is the only type supports hook"
}));
e.prototype[r] = function() {
for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
return n.call.apply(n, d([ this ], e)), i.call.apply(i, d([ this ], e));
};
}(e, t);
}, e.prototype.registerComponent = function(t) {
g(e, t);
}, e.prototype.registerVersion = function(e) {
Object(I.h)(e);
}, e.prototype.registerSdkName = function(e) {
Object(I.g)(e);
}, e.prototype.registerEndPoint = function(e, t) {
Object(I.f)(e, t);
}, e.prototype._useDefaultAdapter = function() {
var e = Y(), t = e.adapter, n = e.runtime;
v.adapter = t, v.runtime = n;
}, e.prototype._formatTimeout = function(e) {
switch (!0) {
case e > 6e5:
return X(J.INVALID_PARAMS, "timeout is greater than maximum value[10min]"), 6e5;

case e < 100:
return X(J.INVALID_PARAMS, "timeout is less than maximum value[100ms]"), 100;

default:
return e;
}
}, F([ Q({
mode: "sync",
title: "Cloudbase 初始化失败",
messages: [ "请确认以下各项：", "  1 - 调用 cloudbase.init() 的语法或参数是否正确", "  2 - 如果是非浏览器环境，是否配置了安全应用来源（https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng）", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + V ]
}), W("design:type", Function), W("design:paramtypes", [ Object ]), W("design:returntype", e) ], e.prototype, "init", null), 
F([ Q({
title: "调用扩展能力失败",
messages: [ "请确认以下各项：", "  1 - 调用 invokeExtension() 的语法或参数是否正确", "  2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册", "如果问题依然存在，建议到官方问答社区提问或寻找帮助：" + V ]
}), W("design:type", Function), W("design:paramtypes", [ String, Object ]), W("design:returntype", Promise) ], e.prototype, "invokeExtension", null), 
e;
}())();
te.useAdapters(p);
t.default = te;
} ]);
});